increase width of AcroFields(iTextSharp)

雨燕双飞 提交于 2019-12-31 02:45:07

问题


I'm using iTextSharp to populate the data to PDF Templates, which is created in OpenOffice. it populating fine, I'm getting proper PDF, but some where i want to increase the width of the AcroField.

I did below code. it is increasing the width but text is not displaying.

AcroFields.Item fldItem = fields.getFieldItem(fieldName);
for (int i =0; i < fldItem.size(); ++i) {
  PdfDictionary widgetDict = fldItem.getWidget(0);
  PdfArray rectArr = widgetDict.getAsArray(PdfName.RECT); 
  float origX = rectArr.getAsNumber(0).floatValue();
  rectArr.set( 2, new PdfNumber( origX + 12 + 60 ) );
}  

in the below image highlighted one. actual string is 10000 SUPERIOROPTICAL 123 4567 89

please help.
thanks.


回答1:


I can't reproduce the problem. I've made this POC: ChangeFieldSize

In this example, I take a form with three fields, among others a "Name" and a "Company" field. I first change the size of the "Name" field, the same way you change the field. Then I fill out the "Name" field and the "Company" field. Note that the order in which I perform these operations is important. Maybe you're doing it the other way round.

The result looks like this:

As you can see, the text isn't truncated the way it is in your screen shot.

So there are two things you can try:

  • change the order in which you change the field rectangle and fill out the field.
  • upgrade to the most recent version of iTextSharp.

If that doesn't help, post a SSCCE.



来源:https://stackoverflow.com/questions/24404413/increase-width-of-acrofieldsitextsharp

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