David Woosley wrote:

This email corrects a typo from the previous one ...

(1) I have three templates with AcroFields:

france.pdf
germany.pdf
england.pdf
OK

(2) I create three stampers with an output stream of ByteArrayOutputStream,
Three different ByteArrayOutputStream objects.

fill in the fields, flatten the content and close each stamper (??? -- I'm
assuming I should close each stamper at this point, but I'm not sure yet).
Close the Stamper, otherwise the PDF won't be complete.

Some of the templates will have identical field names, but I think
flattening each stamper will solve this problem.

The field names will disappear after flattening, so this is OK.

 That gives me these three
Java objects:

stamperFrance -- has 1 to X pages
stamperGermany -- has 1 to Y pages
stamperEngland -- has 1 to Z pages
The stamper objects aren't important anymore at this point.
It should read:

That gives me these three Java objects:
baosFrance, baosGermany and baosEngland

(3) At this point, nothing has been written to disk.  No other writers
exist.  No other document exists.  I want to combine the contents from all
three stampers into one multi-page (X+Y+Z), form-flattened output PDF named
Europe.pdf.
Now you need to have a look at a PdfCopy example.
You will create a PdfReader object with baosFrance.toByteArray()
and add all the pages to a PdfCopy object that creates a file Europe.pdf.
Then you will create a PdfReader object with the byte[] from
baosGermany and also add the pages to the 'European' PdfCopy object.
And so on.

(4) My question:  What the most efficient way to accomplish this goal.

I would change the order of the actions.
In PSEUDO CODE:

PdfCopy:openEurope
while (moreCountries) {
 PdfReader:readCountryFormWithFields
 PdfStamper:createCountryInMemory
 PdfStamper:fillInCountryData
 PdfStamper:flattenFields
 PdfStamper:closeCountry
 PdfReader:readCountryFromBytes
 PdfCopy:addCountryBytesToEurope
}
PdfCopy:closeEurope

br,
Bruno


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to