How can I split up a PDF file into pages C#?

Question: My client has a multi-page PDF file. They need it split by page. Does anyone know of a way to do this - preferably in C#.

Answer: If you need to split multi-page PDF  to single page PDF from C#, maybe you can have a free trial of this software: VeryPDF PDF Split-Merge SDK, which provides competent interfaces which can be used in any programming language like C++, Visual Basic, Delphi, ASP and others.  Please check more information of this software on homage, in the following part, let us check how to split PDF into pages from C#.

Step 1. Download PDF Split-Merge SDK

  • This is Windows application, it can work under all the Windows system both of 32-bit and 64-bit. By the SDK version, you can call it from C#, VB .NET, MS Visual Basic, Borland Delphi, VBA (MS Office products such as Access) and C++ via COM, C and C++ via native C.
  • When downloading finishes, there will be a zip file. Please extract it to some folder then you can split PDF by this software.

Step 2. Split PDF into single pages from C#.

  • When you use this software, please refer to the usage and example template.
  • This software also can help you merge different PDF documents or pages into a single PDF document in a few seconds, modify document information data such as Author, Subject, Title or Keywords to all generated documents, split PDF files into single pages or sets of pages according to odd/even pages and others.
  • Here is one example of splitting  PDF from C#, please have a check.

void main()
{
           BOOL bRet = FALSE;
           char szInPDF[MAX_PATH];
           GetModulePath(szInPDF, "testcmd.pdf");

           PDF_SetMode(0)
           PDF_SetCode("Set your License Key at here")

           char szOutPDF1[MAX_PATH];
           char szOutPDF2[MAX_PATH];
           char szOutPDF3[MAX_PATH];
          GetModulePath(szOutPDF1, "out-001.pdf");
          GetModulePath(szOutPDF2, "out-002.pdf");
          GetModulePath(szOutPDF3, "out-003.pdf");

//Extract pages from an existing PDF file
             HPDF hPDF = PDF_Open(szInPDF);
             bRet = PDF_ExtractPages(hPDF, szOutPDF1, "1-3")
             bRet = PDF_ExtractPages(hPDF, szOutPDF2, "2-6")
             bRet = PDF_ExtractPages(hPDF, szOutPDF3, "10");
             PDF_Close(hPDF);

//Merge several PDF files into one PDF file
         char szMergePDFs[2048];
         strcpy(szMergePDFs, szOutPDF1);
         strcat(szMergePDFs, "|");
         strcat(szMergePDFs, szOutPDF2);
         strcat(szMergePDFs, "|");
         strcat(szMergePDFs, szOutPDF3)
        char szOutMergedPDF[MAX_PATH];
        GetModulePath(szOutMergedPDF, "merged1.pdf")
        bRet = PDF_MergePDFFiles(szMergePDFs, szOutMergedPDF);

//Extract and merge PDF files together
     GetModulePath(szOutMergedPDF, "merged2.pdf");
      sprintf(szMergePDFs, "%s*1,2,3,8-10", szInPDF);
      bRet = PDF_MergePDFFiles(szMergePDFs, szOutMergedPDF);
}

Please check more examples on homepage and downloading folder. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 10.0/10 (2 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)
How can I split up a PDF file into pages C#?, 10.0 out of 10 based on 2 ratings

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!