Legacy notice!

iText 5 is the previous major version of iText's leading PDF SDK. iText 5 has been EOL, and is no longer developed. Switch your project to iText 7, integrating the latest developments.
Check related iText 7 content!

I'm using iText to populate the data to PDF templates, which are created in OpenOffice. The form is populating fine; I'm getting proper PDF, but I want to change the alignment of some fields.

I am using the following code.

fields.setFieldProperty(fieldName, "fflags", PdfFormField.Q_LEFT, null);
Posted on StackOverflow on Jun 19, 2014 by Rajesh

The quadding isn't part of the field flags as you wrongly assumed. It's and entry of the widget annotation dictionary. This is how you change it:

AcroFields form = stamper.getAcroFields();
AcroFields.Item item;
item = form.getFieldItem("fieldLeft");
item.getMerged(0).put(PdfName.Q, new PdfNumber(PdfFormField.Q_LEFT));
item = form.getFieldItem("fieldCenter");
item.getMerged(0).put(PdfName.Q, new PdfNumber(PdfFormField.Q_CENTER));
item = form.getFieldItem("fieldRight");
item.getMerged(0).put(PdfName.Q, new PdfNumber(PdfFormField.Q_RIGHT));

See the AlignField method for the full example.