修改pom文件后,itext生成pdf中文不显示
把工程修改为maven profile多环境读取配置文件后,原来能正常生成pdf文件的功能无法使用了,左思右想,是resource引入的原因导致的,修改后的pom文件如下:
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>**/*.vm</include>
</includes>
</resource>
```
如上所示,未引入字体文件,所以修改如下
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>**/*.vm</include>
<include>**/*.ttc</include>
</includes>
</resource>
```
经测试,本地运行正常,但是打包到centos系统的tomcat后,依然无法使用,后台报错:
xxx/simsun.ttc is not a valid TTF or OTF file
查看本地和centos系统中字体文件,发现两者大小不一致,怀疑是不同系统间maven 压缩、解压缩时导致的,所以修改pom文件为如下:
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>**/*.vm</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.ttc</include>
</includes>
</resource>
```
如此解决无法显示部分字体问题