增加AcroFields的宽度(iTextSharp) [英] increase width of AcroFields(iTextSharp)

查看:154
本文介绍了增加AcroFields的宽度(iTextSharp)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iTextSharp将数据填充到PDF模板,这是在OpenOffice中创建的。它填充得很好,我得到了正确的PDF,但有些我想增加AcroField的宽度。



我做了以下代码。它正在增加宽度,但文本没有显示。

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

在下图中突出显示了一个。实际字符串是 10000 SUPERIOROPTICAL 123 4567 89



请帮助。

谢谢。

解决方案

我无法重现这个问题。我已经制作了这个POC:。


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.

解决方案

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.

这篇关于增加AcroFields的宽度(iTextSharp)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆