gpt4 book ai didi

java - Apache FOP 2.2 使用相对路径包含字体

转载 作者:行者123 更新时间:2023-11-30 07:51:32 25 4
gpt4 key购买 nike

我正在设置一个 fop.xconf 并配置 Apache FOP 可用的字体,我想使用相对路径而不是绝对路径:

<fop version="1.0">

<strict-configuration>true</strict-configuration>
<strict-validation>true</strict-validation>
<base>./</base>
<font-base>./</font-base>
<source-resolution>72</source-resolution>
<target-resolution>72</target-resolution>
<default-page-settings height="11in" width="8.26in"/>

<hyphenation-pattern lang="en" country="ZA">en_ZA</hyphenation-pattern>

<renderers>
<renderer mime="application/pdf">
<fonts>
<directory recursive="true">/Users/me/Code/company/project/src/main/resources/templates/fonts</directory>
<substitutions>
<substitution>
<from font-family="Helvetica" />
<to font-family="OpenSans" />
</substitution>
</substitutions>
</fonts>
</renderer>
</renderers>
</fop>

是否可以将渲染器中的字体目录设置为使用相对路径?

或者可以通过编程方式设置它,在这种情况下我可以使用

this::class.java.getResource("/templates/fonts/MyFont.ttf")

获取完整路径?

2017-10-24 05:24:48,591 WARN  org.apache.fop.apps.FOUserAgent - The font directory ./fonts could not be found.
2017-10-24 05:24:48,591 WARN org.apache.fop.apps.FOUserAgent - The font directory ./templates/fonts could not be found.
2017-10-24 05:24:48,591 WARN org.apache.fop.apps.FOUserAgent - The font directory ./resources/templates/fonts could not be found.

最佳答案

虽然这是一个旧线程,但我可能会补充说,即使在 FOP 2.3 中,问题仍然存在。你可能会发现 this FOP Bug有用的:

  • font-base 已从配置中删除(不在文档中)
  • 使用绝对路径

关于java - Apache FOP 2.2 使用相对路径包含字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46901724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com