How to Extract Pages from PDF on Windows

Tutorials | Extract Pages · How to · C# · Windows Thu. 07 Jul. 2022

PDFs are widely used in many industries such as education, financial, construction, etc. When you work with PDF files, you always need to make some manipulations like extracting pages. Extracting a single or multiple pages from a PDF file is quite simple with ComPDFKit PDF SDK. We are going to show you how to extract pages from PDFs on Windows. Let’s see where we can use extracting pages first. 

 

 

Why Extract Pages from PDFs?

 

There are many situations when PDF users need to extract some pages of the PDF files. Here are some examples: 

 

- To make a presentation about some topic, you find several useful data or materials and try to extract some pages from them.

 

- You have a book in PDF and want to share a part of this book with your friends.

 

- After finishing your work and converting it into a PDF, you have been told to present some information in another PDF.

 

When you have no convenient way to do that, you may choose to type all the information manually. Absolutely, that’s a waste of time. However, most of the office software has already integrated extracting functions. Let’s learn how this can be achieved in code.

 

 

Using ComPDFKit PDF SDK

 

CPDFDocument can extract ranges of pages from one document and put them into a blank document. If you run this operation, you can effectively extract a PDF as you require. 

 

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 a PDF document that contains the pages you want to extract.

 

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

 

- 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");

 

 

More Functions

 

Actually, when you extract some PDF pages, the methods you used are not only extracting but also merging and splitting. To learn more about the related functions, please refer to our developer guides.

 

 

Free Trial

 

Click here for a free trial of our ComPDFKit PDF SDK and you can try to integrate the PDF pages extracting, splitting, and merging into your own application. We have introduced the method to extract PDF pages. Whenever you have a problem when using our SDK, please contact our support team.

Ready to Get Started?

Download our all-in-one ComPDFKit for free and run it to your project within minutes!