Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

RE: [iText-questions] Adding new pages using PdfCopy

Amador, Orlando M. [OBIPR]

2005-09-26


RE: [iText-questions] Adding new pages using PdfCopy

Paulo:

Thanks for the tip that will work just as well.

On another subject, is it possible to open a PDF import all the pages into an array and add them (using ddPage()) to the target document?  If you notice in the inner loop of the sample, it is creating a reader object for ever pass of the outer loop.  I was hopping to read those pages once and them added many times.

Saludos,
Orlando

Orlando M. Amador
Technology Lead
Ortho Biologics LLC
oamador@obipr.jnj.com
(787) 854-1800 x2294



-----Original Message-----
From: Paulo Soares [mailto:psoares@consiste.pt]
Sent: Saturday, September 24, 2005 6:19 AM
To: Amador, Orlando M. [OBIPR]; itext-questions@lists.sourceforge.net
Subject: Re: [iText-questions] Adding new pages using PdfCopy


Create a PDf with a single blank page and use it as needed. newPage won't
work with PdfCopy.
----- Original Message -----
From: "Amador, Orlando M. [OBIPR]" <oamador@obipr.jnj.com>
To: <itext-questions@lists.sourceforge.net>
Sent: Friday, September 23, 2005 11:11 PM
Subject: [iText-questions] Adding new pages using PdfCopy


> I'm appending multiple copies of a PDF to create a larger file.  So far
that
> is working fine using the PdfCopy object.  Now, if the source PDF has an
odd
> number of pages, I need to add one blank page of the target PDF before
> appending more copies of the source file.  The idea is to send this to a
> double sided printer and have page one of the source PDF separate from the
> last page.
>
> I read the tutorial and find that the newPage() will do what I need.  My
> problem is that is not working.  I tried the sample program and it works
as
> expected.  The only difference is that the sample program is using a
> PdfWriter class and I'm using the PdfCopy class.
>
> Any idea on why I'm not getting the expected result?  Does PdfCopy support
> the Document.newPage() method?  Is this the wrong way to add an empty page
> to the target document.
>
> I'm using itext-paulo-154.
>
>
> for ( int ix = 0; ix < formCount; ++ix) {
>      reader = new PdfReader(fileName);
>
>      for ( int ij = 1; ij <= pageCount; ++ij)   {
>          PdfImportedPage page = writer.getImportedPage(reader, ij);
>          writer.addPage(page);
>      }
>
>     reader.close();
>
>     if ( (pageCount % 2) != 0 && (evenPages == true )  ) {
>        document.newPage();
>        document.add(Chunk.NEXTPAGE);
>        document.newPage();
>     }
> }
>
> Saludos,
> Orlando
>
> Orlando M. Amador
> orlandoAmador@yahoo.com
>
>
>

©2008 junlu.com - Jax Systems, LLC, U.S.A.