Merge Document into existing page

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for .NET (v7.x)  /  Display Thread

DynamicPDF Merger for .NET (v7.x) Forum

 Jul 31 2017 1:35 PM
Is there any way to merge an external PDF document into the document you are building starting at a position in the last page of the document. 

Basically we want to be able to append multiple PDF documents that may be less than a full page in size and be able to append these into the flow so that they are not separated by page breaks, but will still flow across pages.

These imported PDF documents contain text and images so we cannot just extract out the text and append the text to the document.

Any help would be appreciated.
Posted by a ceTe Software moderator
Hello,

Yes, it is possible to import and merge pages from an external PDF into a new PDF that is being built. You can do this in a couple of different ways:

1. Import a page from an existing PDF and add it as separate page at the end of the new PDF. For additional samples please refer to the following documentation link.

            //Create a new document object.
            Document document = new Document();

            //add new pages.
            document.Pages.Add(new Page());
            document.Pages.Add(new Page());
            document.Pages.Add(new Page());

            //get second page from an existing PDF.
            ImportedPage existingPDFPage = new ImportedPage(@"f:/ExistingDoc.pdf", 2);
            //add the page at the end of the new PDF.
            document.Pages.Add(existingPDFPage);

            //save the new document.
            document.Draw("final.pdf");

2. Import pages from an existing PDF and add them on a single page on the new PDF. Here you have the option to scale the imported pages if needed. For additional samples please refer to the following documentation link.


            //Create a new document object.
            Document document = new Document();

            //add new pages.
            document.Pages.Add(new Page());
            document.Pages.Add(new Page());
            document.Pages.Add(new Page());

            Page pageWithExistingPDFContent = new Page();

            // Create ImportedPageArea objects and add it to the new page
            ImportedPageArea existingPageContent1 = new ImportedPageArea(@"f:\DocumentD.pdf", 2, 0, 0, 0.5f);
            pageWithExistingPDFContent.Elements.Add(existingPageContent1);
            ImportedPageArea existingPageContent2 = new ImportedPageArea(@"f:\DocumentD.pdf", 3, 0, 300, 0.5f);
            pageWithExistingPDFContent.Elements.Add(existingPageContent2);
            document.Pages.Add(pageWithExistingPDFContent);
           
            //save the new document.
            document.Draw("final.pdf");


Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 8:11 AM.