Edit Existing PDF?

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for Java (v5)  /  Edit Existing PDF?

DynamicPDF Generator for Java (v5) Forum

 Jun 29 2010 1:42 AM
Is it possible to edit, or just add to an existing PDF?

Here is my scenario: I have a PDF which I create with, for example, an empty box drawn at a specific x,y coord. I then want to generate a PDF which will consist of the existing PDF with some dynamic data placed into that box.

For example, have a PDF print with our monthly sales sheet - this can be a long document and contains a lot of data from our database (item #s, prices, etc). However, for that entire month I want to print a dynamic invoice number in the top right corner of each page of that existing document to allow our sales people to generate their invoices on demand and without hogging too many server resources.

I see that I can load a PDFDocument using an existing PDF -- but can I then add new objects to that PDF?

 Jun 29 2010 2:13 AM
Actually figured this one out - this just adds a red circle to an existing PDF:

        final Document doc = new Document();

        final PdfDocument pdfDoc = new PdfDocument( "E:\\Test.pdf" );
        final PdfPageList pageList = pdfDoc.getPages();

        for ( int pageNum = 0; pageNum < pageList.getSize(); pageNum++ ) {
            final PdfPage aPage = pageList.getPdfPage( pageNum );

            final ImportedPage newPage = new ImportedPage( aPage );
            newPage.getElements().add( new Circle( 25, 25, 10, new RgbColor( 255, 0, 0 ) ) );

            doc.getPages().add( newPage );

        final String pdfFilename = "E:\\Result.pdf";
        try {
            final File f = new File( pdfFilename );
            if ( f.exists() ) {
            doc.draw( pdfFilename );
        } catch ( final com.cete.dynamicpdf.GeneratorException e ) {
        } catch ( final Throwable t ) {

All times are US Eastern Standard time. The time now is 5:19 PM.