我有下面的fop.conf,它在Windows下运行得很好:
<?xml version="1.0" encoding="utf-8" ?>
<fop>
<renderers>
<renderer mime="application/pdf">
<fonts>
<fonts><font kerning="yes" embed-url="/Windows/Fonts/arial.ttf" embedding-mode="subset">
<font-triplet name="arial" style="normal" weight="400"/></font>
</fonts>
</renderer>
</renderers>
</fop>
但是,由于应用程序还需要在没有Arial提供的操作系统上运行,所以我决定在src/main/resources/fonts/Arial.ttf
应用程序中添加字体。
所以我试着引用这样的字体:
<?xml version="1.0" encoding="utf-8" ?>
<fop>
<renderers>
<renderer mime="application/pdf">
<fonts>
<directory>file:src/main/resources/fonts/</directory>
</fonts>
</renderer>
</renderers>
</fop>
但它不使用字体。
在调试过程中,我看到fopFactoryBuilder有一个名为baseUri
的字段,是否可以将其添加到fop.conf中,并将其扩展到Arial字体的路径?
我没有fopFactoryBuilder.setFontBaseURL(),因为我需要使用不提供它的旧版本。
在fop.conf
中提供相对路径的最佳方法是什么?
发布于 2022-11-07 10:57:28
这就是诀窍:
<?xml version="1.0" encoding="utf-8" ?>
<fop>
<base>.</base>
<renderers>
<renderer mime="application/pdf">
<fonts>
<font kerning="yes" embed-url="app/src/main/resources/fonts/Arial.ttf" embedding-mode="subset">
<font-triplet name="Arial" style="normal" weight="400"/></font>
<autodetect/>
</fonts>
</renderer>
</renderers>
</fop>
https://stackoverflow.com/questions/74319160
复制相似问题