I’ve created an UnequalPages example for you that shows how it works:
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(dest));
Rectangle one = new Rectangle(70,140);
Rectangle two = new Rectangle(700,400);
document.setPageSize(one);
document.setMargins(2, 2, 2, 2);
document.open();
Paragraph p = new Paragraph("Hi");
document.add(p);
document.setPageSize(two);
document.setMargins(20, 20, 20, 20);
document.newPage();
document.add(p);
document.close();
It is important to change the page size (and margins) before the page is initialized. The first page is initialized when you open()
the document, all following pages are initialized when a newPage()
occurs. A new page can be triggered explicitly (using the newPage()
method in your code) or implicitly (by iText, when a page was full and a new page is needed).