Accusoft.PdfXpress7.Net
Merge Multiple PDFs into One PDF

PDF Xpress™ supports merging multiple source PDF documents into one target PDF document using the InsertPages method.

C# Example
Copy Code
            // This code demonstrates how to merge multiple PDFs into one PDF
            Accusoft.PdfXpressSdk.PdfXpress pdfXpress1 = null;
            Document doc_merge = null;
            InsertPagesOptions io = null;
            Accusoft.PdfXpressSdk.SaveOptions so = null;
            Document doc_new = null;
            try
            {
                pdfXpress1 = new PdfXpress();
                pdfXpress1.Initialize();
                doc_merge = new Document(pdfXpress1);
                io = new InsertPagesOptions();
                PageList pageList = new PageList();
                PageRange pageRange = new PageRange();
                pageRange.StartPageNumber = 0;
                pageList.Add(pageRange);
                io.PageList = pageList;
                int numDocs = 4;
                so = new SaveOptions();
                so.Filename = "c:\\merged.pdf";
                OpenOptions oo = new OpenOptions();
                for (int a = 0; a < numDocs; a++)
                {
                    io.InsertAtPageNumber = a;
                    oo.Filename = "C:\\split" + a + ".pdf";
                    doc_new = new Document(pdfXpress1, oo);
                    io.SourceDocument = doc_new;
                    pageRange.PageCount = doc_new.PageCount;
                    doc_merge.InsertPages(io);
                }
                doc_merge.Save(so);
            }
            catch (System.Exception)
            {
            }
            finally
            {
                if (null != doc_new)
                {
                    doc_new.Dispose();
                }
                if (null != doc_merge)
                {
                    doc_merge.Dispose();
                }
                if (null != pdfXpress1)
                {
                    pdfXpress1.Dispose();
                }
            }
 

See Also

 

 


©2018. Accusoft Corporation. All Rights Reserved.

Send Feedback