Extract Pages from PDF

Extract pages from a PDF

The Java sample extracts pages 1, 4, and 3 into a new PDF document.

Steps

  1. Create a PdfFileEditor instance.
  2. Define the page numbers to extract.
  3. Call extract with the source file, page array, and output file.
  4. Save the extracted pages as a new PDF.

Java example

public static void extractPagesFromPdf(Path inputFile, Path outputFile) {
    PdfFileEditor pdfEditor = new PdfFileEditor();
    pdfEditor.extract(inputFile.toString(), new int[] {1, 4, 3}, outputFile.toString());
}