如何在XML文件中提供当前目录路径



我创建了一个项目。 并创建了文件夹层次结构,如 XML->conf->font

在 conf 文件夹中,我放了我的

XCONF 文件,在字体文件夹中,我放了我的字体(ttf 文件)

现在我想引用 XCONF 文件中的字体。请为我提供解决方案:我的 XCONF 文件

<?xml version="1.0" encoding="utf-8" ?>
<fop>
<renderers>
<renderer mime="application/pdf">
 <fonts>
 <directory>/font</directory>
 <directory recursive="true">/font</directory>
   <auto-detect/>
    <font embed-url="/font/grotesque-mt-1361500685.ttf">
    <font-triplet name="GrotesqueMT" style="normal" weight="normal"/>
    </font>
    <font embed-url="/font/grotesquemt-light.ttf">
    <font-triplet name="GrotesqueMT-Light" style="normal" weight="normal"/>
  </font>
  <font embed-url="/font/grotesquemt-bold.ttf">
    <font-triplet name="GrotesqueMT-Bold" style="normal" weight="bold"/>
  </font>

 </fonts>
</renderer>

我收到以下异常:无法使用嵌入网址'/font/grotesque-mt-1361500685解析字体.ttf

你可以尝试embed-url="./font/...ttf"embed-url="font/...ttf"。前导/正态标识绝对 URL。您的 url 指向文件系统根目录上的字体目录。

最好的问候 Majo

最新更新