How can I merge individual selected pages PDF files into one PDF from C#?

Question: How can I merge individual selected PDF files into one PDF upon download? I do require an C# solution, is there a solution on VeryPDF?

Answer: According to your needs, you need to merge PDF pages from different PDF files. And you need to run the merging process from C#. According to your needs, maybe you can have a free trial of this software: PDF Split-Merge SDK, by which you can also merge pages of PDF and PDF/A compliant documents with practical needs then rearrange pages in an arbitrary order to a brand new PDF file. The SDK version 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 homepage. In the following part, I will show you how to use this software.

Step 1. Free download PDF Split-Merge SDK

  • For uploading and downloading easily, we have compressed the SDK version to zip file. When downloading finishes, please unzip it then you can call it normally.
  • When you use this software, please refer to code template in the extracted folder.

Step 2. Merge PDF pages from different PDF files into one PDF from C#.

  • When you need to merge PDF pages from different PDF files into one brand new PDF from C#, please refer to the following code templates:
  • 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);

    }

  • When you need to merge PDF pages of different PDF files, first you need to extract specified pages from PDF file and then merge them together. There are two steps you need to operate.

By this software, you can merge individual selected PDF files into one PDF from C# solution. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

This entry was posted in PDF Split-Merge and tagged . Bookmark the permalink.

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!