Manually add new page in PDFBox using pdfbox-layout

232 Views Asked by At

I'm using pdfbox-layout to create and manage PDF documents using Document API.

Document document = new Document();

It manages to create new page automatically if the text size increases beyond current page using Paragraph API.

Paragraph paragraph = new Paragraph();

However, I'm unable to add new page manually as and when needed. I want to print some content starting from new page.

1

There are 1 best solutions below

0
Arshad Rehmani On BEST ANSWER

After going through the API's source code, I found that add method accepts parameter of type Element,

document.add(Element element)

And after inspecting all the classes that implements Element interface, I found the one that I need, i.e. ControlElement

So, to add a new page, my code looks like,

document.add(ControlElement.NEWPAGE);