Hi,

I'm trying to concatenate 2 pdfs to the end of an existing document that I
have built as per the itext way (using Paragraphs, etc). The problem is that
the second imported document is being overridden starting at the same place
as the first. So in the case below there are 2 pages of jumbled text (since
the first document is 4 pages and the second is 2 pages).

Was wondering if anyone can help?

        //document already has several pages in it (built using Itext)
        //the first imported document
    document.newPage();


    String urlStr = urlRoot  + "/pdf/import1.pdf";
    PdfReader reader  =new PdfReader(urlStr);
    PdfContentByte cb = writer.getDirectContent();

    PdfImportedPage page1 = writer.getImportedPage(reader, 1);
    cb.addTemplate(page1, 1, 0, 0, 1, 0, 0);
    PdfImportedPage page2 = writer.getImportedPage(reader, 2);
    cb.addTemplate(page2, 1, 0, 0, 1, 0, 0);
    PdfImportedPage page3 = writer.getImportedPage(reader, 3);
    cb.addTemplate(page3, 1, 0, 0, 1, 0, 0);
    PdfImportedPage page4 = writer.getImportedPage(reader, 4);
    cb.addTemplate(page4, 1, 0, 0, 1, 0, 0);

    //the second imported document
    document.newPage();

    String urlStr2 = urlRoot  + "/pdf/import2.pdf";
    PdfReader reader2  =new PdfReader(urlStr);

    PdfContentByte cb2 = writer.getDirectContent();
    PdfImportedPage page5 = writer.getImportedPage(reader, 1);
    cb.addTemplate(page5, 1, 0, 0, 1, 0, 0);
    PdfImportedPage page6 = writer.getImportedPage(reader, 2);
    cb.addTemplate(page6, 1, 0, 0, 1, 0, 0);
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to