Page 1 of 1

Page break Ouput PDF

PostPosted: Tue Dec 01, 2015 1:21 am
by Kellox
I've converted HTML to docx which works great, even converting to PDF. When I add a page break and output it as DOCX it works great with the following code:

Br breakObj = new Br();
breakObj.setType(STBrType.PAGE);

P paragraph = objectFactory.createP();
paragraph.getContent().add(breakObj);
wordMLPackage.getMainDocumentPart().getContent().add(paragraph);

But when I try to output it as PDF with the example: https://github.com/plutext/docx4j/blob/ ... utPDF.java, the page break is gone and all the content before the page break comes right before the next content. I also tried adding a page break to my HTML with: <br style="page-break-after:always">, but that doesn't even display a page break in my docx file. Is this is a bug? Or am I missing something?

Thanks in advance!

Re: Page break Ouput PDF

PostPosted: Fri Dec 04, 2015 12:45 pm
by jason
Try putting your w:br inside w:r instead:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
    <w:p >
      <w:r>
        <w:br w:type="page"/>
      </w:r>
    </w:p>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


If you create a docx in Word, you'll see that's what it does.

Re: Page break Ouput PDF

PostPosted: Fri Dec 04, 2015 1:23 pm
by Kellox
It works! Thanks a lot!

Re: Page break Ouput PDF

PostPosted: Wed Oct 25, 2017 3:27 am
by dwilcoxen
I seem to be having the same issue but my page break is already within a run:

<w:p>
<w:r>
<w:br w:type="page"/>
<w:lastRenderedPageBreak/>
</w:r>
</w:p>

The page break is recognized when I open the document in Word but the PDF converter (I'm testing with the online one at this point) ignores the break.

Re: Page break Ouput PDF

PostPosted: Wed Oct 25, 2017 6:45 am
by jason
That sounds odd. Feel free to post a sample docx or email it to me (jason@plutext.org) and I will take a look.