Software Companions - Gerber and HPGL Viewers

Merge PDF files with scConverter

Combine multiple PDF files into a single multipage PDF

Merging or combining multiple PDFs into a single file makes it much easier to manage and organize your documents. You won't need to keep track of multiple files, which can be especially useful for projects, reports, or presentations that have multiple components.


With scConverter you can easily add PDF merging functionality to your application.
There are 4 functions available related to merge that are very easy to use. With these functions You can combine all pages, or only a selection of pages, from the individual PDF files.
The merge interface consists of the following functions:

  • HRESULT PDFMergeInit(void)
  • HRESULT PDFMergeAddFile(BSTR PDFFileName)
  • HRESULT PDFMergeAddFileEx(BSTR PDFFileName, BSTR PageInformation)
  • HRESULT PDFMergeClose(BSTR PDFOutputName)

To create a new merged PDF file, you start with calling the PDFMergeInit function.
Then you can start adding files and pages using one of the following two functions:

  • PDFMergeAddFile
  • PDFMergeAddFileEx

The first function, PDFMergeAddFile, will add all pages from the given file to the combined PDF file.
The second function, PDFMergeAddFileEx, have a second parameter that may be used to control which pages to include from the added PDF file.
Passing for example a page string like "1,2,3,10" will only include page 1,2,3 and 10 from the given PDF.
When all required files and pages are added, you create the new PDF using PDFMergeClose, the parameter is the name of the output PDF.

Sample code for merging pages from 3 different PDF files:


scconverter.PDFMergeInit(); //Start a new PDF
scconverter.PDFAddFile("filea.pdf"); //Add all pages from filea.pdf
scconverter.PDFAddFileEx("fileb.pdf", "1,2" ); //Add page 1 and 2 from fileb.pdf
scconverter.PDFAddFileEx("filec.pdf", "2,3,5,10); //Add page 2,3,5 and 10 from filec.pdf
scconverter.PDFMergeClose( "output.pdf" ); //Create new file named output.pdf

The new file named output.pdf will then contain:

  • All pages from filea.pdf
  • Page 1 and 2 from fileb.pdf
  • Page 2,3,5 and 10 from filec.pdf


Sample Application

You may also take a look at the scMergePDF C# sample to see see how you may use scConverter in an application.
This sample shows a preview of each page in the source PDF file, and let you include all or just selected pages into the combined final PDF.
The complete source code for this sample application is included in the SDK download.



Download



Buy



Documentation