Martin Weiss wrote:
> Based on an earlier recommendation I am trying to replace PdfCopy by 
> PdfWriter 
> (concatenation of a few PDFs). Close of the document fails. What's about 
> forcing a new page ?

document.newPage();

See below:
> Document document = new Document(...);
> document.open();
> PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream
> ("out.pdf");
> 
> PdfReader reader = new PdfReader("in_1.pdf");
> int total = reader.getNumberOfPages();
> for (int i = 1; i <= total; i++) {
>    PdfImportedPage page = writer.getImportedPage(reader, i);
>    writer.getDirectContent().addTemplate(page, 0, 0);
document.newPage();
> }
> reader = new PdfReader("in_2.pdf");
> int total = reader.getNumberOfPages();
> for (int i = 1; i <= total; i++) {
>    PdfImportedPage page = writer.getImportedPage(reader, i);
>    writer.getDirectContent().addTemplate(page, 0, 0);
document.newPage();
> }
> document.close();

However, I'm not sure if the mechanism used by PdfSmartCopy
was implemented for getImportedPage(). I'd have to check the
code (but I'm busy with something else right now); or you
can give us feedback: is the background template added more
than once?
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to