Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iText add new page

Tags:

java

itext

rtf

How can you add a new page to an iText document? document.newPage(); doesn't seem to work.

I am using iText with RTF support from http://sourceforge.net/projects/itextrtf/

Part of my code:

Font titleFont = new Font(Font.COURIER, 14, Font.BOLD);
document.add(new Paragraph("Title1", titleFont));

Table table = new Table(4);
table.setBorderWidth(0);

// Filling table

document.add(table);

document.newPage();

document.add(new Paragraph("Title2", titleFont));

Table table = new Table(4);
table.setBorderWidth(0);

// Filling table

document.add(table);
like image 408
Thizzer Avatar asked Nov 26 '10 11:11

Thizzer


1 Answers

Edit: Re your updated question with code, neither of the below seems to apply. Leaving in case they help someone else out.

Calling newPage tells iText to place subsequent objects on a new page. The new page will only actually get created when you place the next object (at least, that's what it does for me). Also, newPage only creates a new page if the current page is not blank; otherwise, it's ignored; you can use setPageBlank(false) to overcome that.

like image 193
T.J. Crowder Avatar answered Oct 25 '22 14:10

T.J. Crowder