How to: Extract Pages from a Document

  • 2 minutes to read

You need a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.

This example shows how to extract the first page from a document into a separate PDF document.

To accomplish this task:

  • Use the PdfDocumentProcessor.LoadDocument method to load a source document;
  • Call the PdfDocumentProcessor.CreateEmptyDocument method to create an empty target document;
  • Add the first page from the source document to the target document.

    Access the target document using the PdfDocumentProcessor.Document property. The PdfDocument.Pages property provides access to the pages' collection. Add pages to the collection using the Add method. To access the first page in the page collection of a source document, use the zero page index.

    When you add a page from another document, all page content, including bookmarks referring to this page, is copied to the resulting document.

using DevExpress.Pdf;

namespace ExtractFirstPage {
    class Program {
        static void Main(string[] args) {

            using (PdfDocumentProcessor source = new PdfDocumentProcessor()) {
                using (PdfDocumentProcessor target = new PdfDocumentProcessor()) {
See Also