Thank you for your fast reply Bruno.
I still need a tip about how to do this:
> Use PdfWriter.getImportedPage and add the PdfImportedPage
> to the direct content
Here is a (really simplificated) sample code:
Document document = new Document();
resp.setContentType("application/pdf");
PdfWriter writer = PdfWriter.getInstance(document, resp.getOutputStream());
document.open();
/* do something with the document */
document.newPage();
/* here is where I need the last page of a PDF */
PdfReader reader = new PdfReader("myPDF.pdf");
int n = reader.getNumberOfPages();
PdfImportedPage page;
page = writer.getImportedPage(reader, n);
/* and here is my problem: */
writer.??????
Can you help me please?
Cheers,
Marc.
Bruno Lowagie (iText <bruno <at> lowagie.com> writes:
>
> Marc Font wrote:
> > I'm generating a PDF and before close the document, so before send the
> > HttpServletResponse, I need to add an existing PDF in the end of the
document.
>
> You are generating a PDF with PdfWriter, right?
> So you have this writer object:
> PdfWriter writer = PdfWriter.getInstance(document, baos);
> At the end of the document, before you do document.close();
> you should create a PdfReader object that is able to read
> the existing document. Ask the reader for the page size of
> the first page of this existing document, change the page
> size of the document you are generating accordingly, and
> then do document.newPage();
>
> Use PdfWriter.getImportedPage and add the PdfImportedPage
> to the direct content. If you want to add more than one
> page from the existing PDF, repeat this process (change
> page size, do new page, add an imported page).
>
> There are other ways to do it that may be better or worse;
> it all depends on your exact requirements.
>
> > I've been trying to figure out how to do it with both examples of how to
> > concatenate documents and don't get it.
>
> This is actually a very funny remark: you tried figuring
> out how to do it with 'both examples'. There are plenty of
> examples that explain how to do this on the net, it is very
> hard to guess which two examples you tried.
>
> br,
> Bruno
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> iText-questions mailing list
> iText-questions <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
>
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/