We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page break support in Aspose.PDF

Hi,

I want to know whether the Aspose.PDF or Aspose.PDF.kit supports page breaks during PDF generation. Something like this:-

Page information in Page 1

Page information in Page 2

Page information in Page 3

Whether this is possible through Aspose PDF API in Java? If so, please provide some sample code. Please do respond to this.

Thanks,

Rithu

Hello Rithu,

Thanks for your interest in our products.

As per Aspose.Pdf Document Object Model (DOM) by default every section starts over the new page. So as per your requirement, you can add the particular information in one section that you need to display over one page and then add the other set of information in second section which you need to display over other page and so on. Please try using the following code snippet and in case you still face any problem, please feel free to contact.

Just for your information, I've set the orientation of second section to Landscape. The resultant PDF is in attachment, please take a look.

[Java]

Pdf pdf1 = new Pdf();

Section sec1 = pdf1.getSections().add();
Text text1 = new Text("This is text in section1.");
text1.getMargin().Top = 30;
sec1.getParagraphs().add(text1);

Section sec2 = pdf1.getSections().add();
sec2.setIsLandscape(true);
Text text2 = new Text("This is text in section2.");
text2.getMargin().Top = 30;
sec2.getParagraphs().add(text2);

Section sec3 = pdf1.getSections().add();
Text text3 = new Text("This is text in section3.");
text3.getMargin().Top = 30;
sec3.getParagraphs().add(text3);

pdf1.save("D:/pdftest/MultiPagePDF_Test.pdf");

For more information, you can also check Working with Sections and Section