0

I have a pdf which contain acrofields. When i do stamping of those field and make this pdf flattened, everything is working fine. I got the pdf and all the acrofields have proper value. Problem is when I am opening this stamped file, Acrobat opens it sucessfully but when i scrolled down to the 6 page where my acrofields are present, it displays Error popup with following msg:

A error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct this problem.

I am also sending the link of the pdfs(pdf with acrofields and stamped pdf) for which error is occuring.

pdf file without filling acrofield

stamped pdf file

Code used to stamp the pdf file :-

`

PdfReader reader = new PdfReader(location1);
Integer i=0;
PdfStamper stamper = new PdfStamper(reader,new FileOutputStream(location2));
AcroFields form2 = stamper.getAcroFields();
Set<String> fields2 = new HashSet(form2.getFields().keySet());
for(String s1 : fields2)
{
   i = i+1;
   form2.setField(s1, i.toString());
}
stamper.setFormFlattening(true);
stamper.close();`

Scenario when this error comes : 1) stamping using itext 2.0.8 ( both in program(where stamping is done in main method) and with web application)

2) stamping using itextpdf 5.4.1(error msg appears only when stamping flow is running in web application. but if i generated stamped pdf using program(with main method), no error msg appear).

Please help me out.

user906221
  • 29
  • 2
  • 4
  • *error msg appears only when stamping flow is running in web application. but if i generated stamped pdf using program(with main method* - iText is agnostic in respect to whether it is run in a web app or stand-alone. Thus, something else is fishy in the web application environment. – mkl Mar 14 '14 at 12:42

1 Answers1

1

The original form Form-I-9.pdf you start with already is erroneous, the appearance content stream of one of the form fields contains a syntax error. But as the Adobe Reader is used to re-create field appearances under certain circumstances from the field values, it seems to not care.

When the form fields are flattened, this erroneous appearance content stream becomes a xobject content stream. The Reader knows no way to repair this syntax error anymore (after all there is no field anymore whose value could be used). Thus, you get the error message.

The issue itself is located on page 7, not 6 (as soon as the Reader starts to render page 7 it appears). It is the appearance stream of the field CountryOfIssuance[0] in object 91 0 in Form-I-9.pdf which becomes object 43 0 in the flattened testFormI9.pdf:

q
1 1 273.543 13.12 re
W
n
BT
/CourierNewPSMT 10 Tf
2 5.8549 Td
17.01 TL
 Tj
ET
Q

As you see the parameter of the Tj operation is missing.

mkl
  • 90,588
  • 15
  • 125
  • 265