1

I am using this code to flatten the pdf.There is a form field named "DBA_Name".This is multiline.It is vertically bottom aligned.But after flatten the pdf,it is getting top aligned. I have no idea why it is showing this behaviour as it should be bottom aligned. My Code is-

  PdfReader readerFlat = new PdfReader(inputFilePath);  
  FileOutputStream foutFlat = null;
  PdfStamper stamperFlat = null;
  foutFlat = new FileOutputStream(outputFilePath);              
  stamperFlat = new PdfStamper(readerFlat, foutFlat); 
  stamperFlat.setFormFlattening(true);
  stamperFlat.close();

The link for the PDF is http://www.mediafire.com/download/5ccqjvg4676h0j2/Test.pdf

Thanks in advance.

4

1 回答 1

2

Your allegation that the field "is vertically bottom aligned" confused me, because ISO-32000-1 doesn't define any parameter that allows vertical alignment of the contents of an AcroForm form field. Please read the spec if you don't believe me.

I've looked at the PDF you shared with us, and I see that it contains a hybrid form. It contains a description of the fields based on AcroForm technology, as well as a description based on the XML Forms Architecture (XFA). AcroForm technology predates XFA technology. XFA introduced new concepts, such as vertical alignment.

You are making the assumption that the core iText flattens the XFA form. That assumption is wrong. The core iText only looks at the AcroForm definition and ignores the XFA stream when flattening the form. Only the closed source iText add-on XFA Worker can flatten XFA.

Summarized: you're expecting iText to interpret a property that isn't there (at least not in the AcroForm field). You'll have to search for a workaround.

于 2013-05-23T06:48:34.543 回答