Extract Pages from PDFs with ComPDFKit - ComPDFKit/compdfkit-pdf-sdk-windows GitHub Wiki

When you extract pages, you can choose the pages you want to extract freely with ComPDFKit PDF SDK. You can also choose how the extracted pages will be put โ€” in one file or each page in a separate file. About the original PDF document, you can choose to keep or delete the extracted pages.

  • All the Pages
  • Odd Pages
  • Even Pages
  • Custom Range

The steps involved are quite straightforward, letโ€™s take a look at how easy it is in code.

Create a Blank PDF Document

CPDFDocument document = CPDFDocument.CreateDocument();

Open Another PDF

Open a PDF document that contains the pages you want to extract.

CPDFDocument document1 = CPDFDocument.InitWithFilePath("filePath");

Extract Specific Pages

Extract specific pages from the PDF document that you just opened, and import them into the blank PDF document.

// Pages that need to be extracted, e.g. 2 to 5 pages document.ImportPagesAtIndex(document1,"2-5",0);

Save the document

// Save path document.WriteToFilePath("savePath");