Add Page Breaks in PDF

Add page breaks in a PDF

Use this workflow when a page needs to be split into multiple pages at a known Y position.

Steps

  1. Create a PdfFileEditor instance.
  2. Build one or more PdfFileEditor.PageBreak entries with the page number and break position.
  3. Pass the page break array to addPageBreak.
  4. Save the updated PDF document.

Java example

public static void addPageBreaksInPdf(Path inputFile, Path outputFile) {
    PdfFileEditor pdfEditor = new PdfFileEditor();
    pdfEditor.addPageBreak(inputFile.toString(), outputFile.toString(), new PdfFileEditor.PageBreak[] {
            new PdfFileEditor.PageBreak(1, 400)
    });
}