Strüßmann, Mirko (KRZ) wrote:
> Hi all,
>  
> I have a data file (CSV) and a PDF form template with it's fields named
 > like the columns within the data file. I now want to create a PDF file
 > with one page for every data row. So every page of the created PDF file
 > should consist of the PDF form with the values from CSV file filled 
in the form fields.

You need one file with everything inside?

> I've found two possible solutions on 
> http://itext.ugent.be/articles/eid-pdf/index.php.

I hope these examples made you curious about the book ;-)

> The first (http://itext.ugent.be/articles/eid-pdf/test/EIDFormTemplate.java) 
> does use
> a PdfCopy and a PdfStamper to fill the form fields of the PDF form template 
> and then
 > add the filled in document to the PdfCopy. The drawback of this 
solution is that it
> is very slow, it uses a lot of memory and it creates real huge PDF files.
> In fact using it with only 7000 data rows and "-Xmx1024m" lead to an 
> OutOfMemoryError.
 > (And in production we are talking about more than 100,000 data rows.)

You are probably using the example literally.
You don't have to create all the files in memory.
You could create every PDF as a file, then afterwards
concatenate them, saving a lot of memory.
Moreover section 16.1.5 of the book will give you some tips
on how to save CPU (read page 512).

However, with this approach, you will still end
up with huge PDF files.

 > The second 
(http://itext.ugent.be/articles/eid-pdf/test/BatchFormFill.java)
 > possible solution is to extract the fields coordinates from the
 > PDF and then to simply add the form as a template to the
 > getDirectContentUnder() and in the second step to draw the data values
 > to the coordinates of the form fields. This is very fast, produces
 > very small PDF files and uses a lot less memory than the first
 > solution. The drawback is that the values does not automatically use
 > the font that the designer of the PDF form template defined for the
 > corresponding form field.

Retrieving the font defined by the designer is not impossible,
but may be difficult, depending on what to expect (Chinese? Arabic?
Japanese?)

br,
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to