Abdullah Jibaly wrote:
> Hi All,
> 
> I'm trying to use iText to fill out an AcroForm. Everything seems to
> work well using the code below except the field that has the text
> filled into it becomes shifted down a couple pixels. If I open it up
> in Acrobat afterwards (filled.pdf) and click back in that field it
> shifts back up, and if I enter something and save the form it becomes
> fixed again. Any ideas on whats going on?

As strange as it may seem, the 'baseline' of the content of fields
in an AcroForm has changed from Adobe (or Acrobat) Reader version
to Adobe Reader version.
iText creates an appearance for your field content assuming a specific
baseline, but when you click/change the content, the appearance is
created by Adobe Reader using the baseline as defined by that version.
That's more or less what's going on.
Now to work around this problem, try this:

> PdfReader reader = new PdfReader("form.pdf");
> PdfStamper stamper = new PdfStamper(reader, new 
> FileOutputStream("filled.pdf"));
> AcroFields form = stamper.getAcroFields();
form.setExtraMargin(0, -2);
> form.setField("dispatch_no", "ABCxYZ123");
> stamper.close();

-2 is an offset for the Y-coordinate in user units (1/72 inch).
Experiment with it till you are satisfied with the result.
Of course: when testing with other versions of Adobe Reader,
the problem may resurface in the other direction...

br,
Bruno

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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