« Return to Thread: Generation of Multiple Page PDF Document is slow

Re: Generation of Multiple Page PDF Document is slow

by Abhishek Srivastava-2 :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
Thanks Bruno,
 
could you clarify the following lines in your code snipped
 
Letter letter = new Letter();
 writer.setPageEvent(letter);
 
what is letter over here?
 
regards,
Abhishek.
 
On 8/4/06, bruno <bruno@...> wrote:
As promised, this is the procedure I use to create a 27.000+ page document
really fast using an existing 1-page PDF document with a form.

My class Letter extends PdfPageEventHelper.

In the onOpenDocument method
1. I read the existing PDF and retrieve the fields and their coordinates
I store these coordinates for later use.
2. I read the page into a PdfImportedPage and store this page in a
member variable 'page'

In the onStartPage method, I do:
writer.getDirectContent().addTemplate(page, 0, 0);

In the main method, I go through the 5 steps of document creation:
1. Document document = new Document();
(in your case, it would probably be a good idea to retrieve the page
size from the original PDF)
2. PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("new.pdf"));
Letter letter = new Letter();
writer.setPageEvent(letter);
3. document.open();
4. I add content
I loop over all the records in my database and I add it to the PDF
using ColumnText
the coordinates used in the ColumnText objects, are the ones retrieved
in the onOpenDocument method.
After each record, I do document.newPage();
I don't worry about the 'template', the imported page is added
automatically in the page event.
5. document.close();

There are other ways to do it, and the book will give you
another example using setField and setFieldCache, but
the procedure described above is faster because it cuts
a lot of corners.

best regards,
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@...
https://lists.sourceforge.net/lists/listinfo/itext-questions


-------------------------------------------------------------------------
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@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

 « Return to Thread: Generation of Multiple Page PDF Document is slow