oleole wrote:

Hello all,

I'm reading a big pdf file, reading a tag inside each
pages and creating a new pdf file by copying the
current page to it.

I see that you are using PdfWriter, and that you overwrite
your document over and over again. PdfCopy or PdfStamper
are probably better suited for your needs.

My problem is that I manage to
copy one page to my new pdf but not more than one,

That's normal. Everytime you create a new FileOutputStream,
the old file is deleted in favor of the new file. I see that you try
to concatenate files, but you are making the wrong assumption
that PDF is as simple as plain text.

if
I reopen my newly created pdf in order to add a new
page to it, it in facts overwrite it (worst when I
open the pdf in acrobat it rebuild it ?).
The rebuild probably happens because you have different
PDF files with different cross-reference tables glued to each
other. That's not the way it works. (If it were, you wouldn't
need iText to take care of the integrity of the PDF syntax.)

I have to
close the document because I'm in fact in a loop

Maybe you should think about your design to see if it's really
necessary to close the document. I think it's possible to do it
otherwise.

For instance: you could first burst your original PDF file
(i.e. use the Burst class to split the PDF in separate pages)
and then copy the pages you need with PdfCopy.

You could keep the reader that reads the source file
and keep the loop creating another reader that reads
the tmp file and use PdfStamper.insertPage to add a
new page when needed.

There are several other solutions. These are just some hints.
br,
Bruno


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to