Align AcroFields in java

怎甘沉沦 提交于 2019-12-02 05:16:44

问题


I'm using iTextSharp to populate the data to PDF Templates, which is created in OpenOffice. it populating fine, I'm getting proper PDF. In that PDF some where summary will come, that place i want align that text against the Template.

I'm doing below code but it does not work.

fields.setFieldProperty(fieldName, "fflags", PdfFormField.Q_LEFT, null);

Please Help.
Thanks.


回答1:


Assuming that you have a pure AcroForm and not a hybrid form as I indicated in my comment, this is how you change the quadding of a field:

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));

The quadding isn't part of the field flags as you wrongly assumed. It's and entry of the widget annotation dictionary.



来源:https://stackoverflow.com/questions/24301578/align-acrofields-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!