Place New Content on existing PDF Pages

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for Java (v6)  /  Place New Content on existing PDF Pages

DynamicPDF Generator for Java (v6) Forum

Hi,
  please provide some examples for below requriement

we have 3 input pdf pages and 1 output pdf file with 80 pages., if output file has same page which is in input file then we need to replace with new content the particular page in the output pdf with the input pdf file.
Thanks
Padmaja
Posted by a ceTe Software moderator
Hello Padmaja,

You can insert the PDF page to an already existing PDF at desired position and you can make final PDF by skipping a particular page in the already existing PDF document. Please note that you will need to know what page you are want to replace and at what position you would like to place the new PDF page. It is not possible to compare two PDF documents and pages using our DynamicPDF Merger for Java product.

Sample code.

        PdfDocument pdf=new PdfDocument("C:/temporary/AllPageElements.pdf");
        MergeDocument finalDocument=new MergeDocument();
        //The below code appndends the PDF document by leaving the firsrt page.
        finalDocument.append(pdf, 2, 5);

        //Code to insert the page into finalDocument.
        MergeDocument inputPdf=new MergeDocument("C:/temporary/DocumentC.pdf");
        Page page=inputPdf.getPages().getPage(0);
        finalDocument.getPages().add(0, page);
        finalDocument.draw("C:/temporary/Mydocument.pdf");

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 1:10 PM.