IText5填充PDF表单使用自定义字体中文生效而英文和数字不生效?

为什么使用IText5填充PDF时,使用自定义字体(特别是某些新兴的字体)时中文生效,英文和数字不生效?

查了相关资料,发现无果,或者都不生效。

看了api接口文档,发现有解决方案,特地记录一下:

 com.itextpdf.text.pdf.AcroFields#setFieldProperty(java.lang.String, java.lang.String, java.lang.Object, int[])中可设置字体。

具体是这么描述的:

Sets a field property. Valid property names are:
textfont - sets the text font. The value for this entry is a BaseFont. 
textcolor - sets the text color. The value for this entry is a BaseColor. 
textsize - sets the text size. The value for this entry is a Float.
bgcolor - sets the background color. The value for this entry is a BaseColor. If null removes the background. 
bordercolor - sets the border color. The value for this entry is a BaseColor. If null removes the border. 

见名之意:设置文本字体,设置的值即是咱们加载的自定义字体,如:

BaseFont font = BaseFont.createFont("/path/AlibabaPuHuiTi-3-45-Light.ttf",
 BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED)

发现生效了。

相关推荐

  1. C#使用iText7画发票PDF——字体定义颜色

    2024-03-20 08:18:01       18 阅读
  2. PDF模板填充,基于IText5

    2024-03-20 08:18:01       31 阅读
  3. PDF模板填充,基于IText5(改进版)

    2024-03-20 08:18:01       42 阅读
  4. 基于IText7 PDF模板填充

    2024-03-20 08:18:01       41 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-20 08:18:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-20 08:18:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-20 08:18:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-20 08:18:01       20 阅读

热门阅读

  1. 创建一个针对单个问题的GPT风格语言模型

    2024-03-20 08:18:01       19 阅读
  2. 【vivado】ILA使用

    2024-03-20 08:18:01       18 阅读
  3. 在CentOS 7上使用Ansible安装Nginx

    2024-03-20 08:18:01       20 阅读
  4. 策略模式在项目中实际应用

    2024-03-20 08:18:01       22 阅读
  5. C++系统设计题目

    2024-03-20 08:18:01       18 阅读
  6. 简述JVM

    简述JVM

    2024-03-20 08:18:01      17 阅读