Aem Apache FOP |自定义字体|相对URL不工作
我有配置文件来加载ApacheFop的自定义字体。我正在努力配置服务器上的嵌入url,以便字体url根据服务器域的不同而变化 我已尝试将url属性值嵌入为: 非工作嵌入URL:Aem Apache FOP |自定义字体|相对URL不工作,aem,apache-fop,Aem,Apache Fop,我有配置文件来加载ApacheFop的自定义字体。我正在努力配置服务器上的嵌入url,以便字体url根据服务器域的不同而变化 我已尝试将url属性值嵌入为: 非工作嵌入URL: 嵌入url=“context:/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf” 嵌入url=“文件:/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf” 工作嵌入url: 嵌入url=”htt
- 嵌入url=“context:/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf”
- 嵌入url=“文件:/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf”
- 嵌入url=”http://localhost:4503/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf"
<?xml version="1.0"?>
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<font kerning="yes"
embed-url="context:/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf" -- this doesn't
embedding-mode="subset">
<font-triplet name="SimSun" style="normal" weight="normal" />
</font>
<font kerning="yes"
embed-url="file:/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf" -- this doesn't
embedding-mode="subset">
<font-triplet name="Batang" style="normal" weight="normal" />
</font>
<font kerning="yes"
embed-url="http://localhost:4503/etc/designs/projectName/clientlibs/pdffonts/Batang.ttf" -- this works
embedding-mode="subset">
<font-triplet name="Batang" style="normal" weight="normal" />
</font>
</fonts>
</renderer>
</renderers>
</fop>
相对路径的“起点”:
- 如果配置文件具有
元素(作为文档根元素的直接子元素),则其值用于解析相对字体路径字体基
- 否则,将使用
元素的值base
- 分发中包含的默认配置文件具有元素
,这意味着必须将相对路径解释为相对于配置文件的位置
font base
和base
的值也可以是相对的,在这种情况下,它们指的是配置文件路径
<?xml version="1.0"?>
<fop version="1.0">
<base>.</base>
<font-base>/Users/lfurini/Library/Fonts</font-base>
<!-- other possible examples:
<font-base>.</font-base>
<font-base>../fonts</font-base>
-->
<!-- ... -->
</fop>
(使用FOP 1.1、2.0和2.1进行测试)
(披露:我是一名FOP开发人员,虽然现在不是很活跃)对于FOP-2.1,有一个“允许字体文件/目录的相对路径”的补丁。我通过从代码添加完整路径到应用程序解决了这个问题。并从配置文件中添加了后来的patr setBaseURL(this.getServletContext().getInitParameter(“我的路径”) 在配置中 嵌入url=“font/newfont.ttf”
在使用AEM时,我最终为ApacheFOP每次运行模式创建了多个配置文件。这符合我的要求,但我想一定有更好的方法来做到这一点。有可能将一个配置导入另一个配置吗?我需要在每个配置相同的字体,但不同的pdf-x模式设置。知道吗?但这不是相对路径,而是硬编码路径。相对是指使用整个应用程序的上下文路径。您的解决方案“与可移植性冲突”。
<!-- directly in the base folder -->
<font kerning="yes" embed-url="font1.ttf">
<font-triplet name="font1" style="normal" weight="normal"/>
</font>
<!-- in a "sister" folder -->
<font kerning="yes" embed-url="../otherFonts/font2.ttf">
<font-triplet name="font2" style="normal" weight="normal"/>
</font>
<!-- in a sub-folder -->
<font kerning="yes" embed-url="specialFonts/font3.ttf">
<font-triplet name="font3" style="normal" weight="normal"/>
</font>
<!-- absolute path -->
<font kerning="yes" embed-url="/Users/lfurini/Library/Fonts/font4.ttf" embedding-mode="subset">
<font-triplet name="font4" style="normal" weight="normal"/>
</font>