Hello everyone,
I'm new to iText, so please excuse if my knowledge of how PDF and iText work
is low.
I need to describe the procedure we're doing as it's the best way to
summarize what we're trying to accomplish, sorry for this long e-mail.
Our customer had a PDF form that was printed and sent via paper mail. This
form had to be filled by hand by customers and then sent back via paper mail
or fax with "attachments" (i.e. copies of other documents).
We've been requested to bring this procedure to the web. Sadly the employees
who handle the filled forms are used to handle PDF/TIFF files produced from
scanning the paper letters or faxes sent back by the users; our customer
wanted this procedure to stay the same with the PDF with possibly the same
appearance.
So we set up a web form for the user (similar to the paper form), where the
user may attach images (= electronic scans of additional documents). When
the user confirms the form, we produce a PDF that is then sent to our
customer's employees that will process this form.

iText comes handy to create the PDF that are sent to the employees; what we
thought to do what this:
1. put an AcroForm on the PDF that was originally sent to the users via
paper mail
2. each time the user fills the web form, use the PDF with form as a
template, filling the form with the data the user has inserted and adding a
page to the document for every image the user has attached to the form.

We thought that using by a single PdfReader+PdfStamper we could do the
trick, but it turned out that we couldn't add pages to the document in the
PdfStamper.
We then wrote code as follows:
* first a PdfStamper+PdfRreader is used to fill and flatten the form with
the user data; the PdfStampler saves on a first temporary file.
* a new Document+PdfWriter is created containing all the attached images
(one on each page), saving a second temporary PDF file
* an instance of PdfCopy is used to import the first page from the first
temporary file and all the pages from the second temporary file.

iText code seems working, but Acrobat shows an error when opening the
resulting document saying that "There was an error processing a page. There
was an error reading this document (18)." The merged document shows a blank
first page (the one that should contain the form filled by the user) while
all the other pages (the attached images) are correctly shown.
If I open the first and second temp file in Acrobat (9.0) and do a "Combine
/ Merge Files In a Single PDF", the resulting PDF shows correctly all the
pages; this second PDF is some KB bigger and analyzing its structure with
PDF Can Opener I find that the file produced by Acrobat contains some
additional metadata.

I know that we could add attachments to the document and using the simple
PdfReader+PdfStamper works, but sadly this solution isn't accepted by our
customer (it's basically a CU - Clueless User - problem, I know it's sick
but we cannot change that).

Can anybody here help me understand if and what I'm doing wrong? Is there
another (better) way to do this? I can provide on request source code and
the PDF used.

Thanks in advance.

LM

-- 
View this message in context: 
http://www.nabble.com/Help%3A-filling-a-PDF-with-a-form-and-adding-extra-content-tp25059788p25059788.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to