Split PDF from Beginning

Split PDF from beginning

The Java sample extracts the first three pages from the source document.

Steps

  1. Create a PdfFileEditor instance.
  2. Call splitFromFirst with the source file, number of pages to keep, and output file.
  3. Save the new PDF document.
public static void splitPdfFromBeginning(Path inputFile, Path outputFile) {
    PdfFileEditor pdfFileEditor = new PdfFileEditor();
    pdfFileEditor.splitFromFirst(inputFile.toString(), 3, outputFile.toString());
}