Apache FOP:在 PDF 中显示 UTF-8 字符(不嵌入?)

发布于 2024-08-02 06:56:32 字数 1029 浏览 5 评论 0原文

我正在尝试使用 FOP 导出包含 UTF-8 字符的 PDF,最好不需要嵌入字体。
以下代码:

<fo:block font="10pt Helvetica" text-align="justify" space-after="10pt" space-before="8pt" keep-with-previous="auto" keep-together.within-page="auto"> 
  <fo:block font-weight="bold" color="gray">Summary</fo:block>
  <fo:block text-indent="1em" keep-with-previous="always">
    <fo:block text-indent="1em" space-before="4pt">
      <fo:block text-indent="1em" space-before="4pt">私はガラスを食べられます。それは私を傷つけません
      </fo:block>
    </fo:block>
  </fo:block>
</fo:block>

在 PDF 中生成 ####################。我知道这个问题: http://xmlgraphics.apache.org/fop /faq.html#pdf-characters

当我进入“文档属性”->“字体”时,Helvetica 字体会以“编码:ANSI”列出。有办法改变这个吗?

如果我要嵌入,在无法访问 Helvetica.ttf 的情况下执行此操作的最佳方法是什么?我尝试过使用 DejaVuSans,但最终我用方块代替了 # 符号。

请注意,这不是从命令行一次性使用(这将是一个开始),而是对现有应用程序的扩展。我正在尝试支持 UTF-8 字符而不需要太复杂。

I'm trying to use FOP to export a PDF with UTF-8 characters, preferably without needing to embed the font.
The following code:

<fo:block font="10pt Helvetica" text-align="justify" space-after="10pt" space-before="8pt" keep-with-previous="auto" keep-together.within-page="auto"> 
  <fo:block font-weight="bold" color="gray">Summary</fo:block>
  <fo:block text-indent="1em" keep-with-previous="always">
    <fo:block text-indent="1em" space-before="4pt">
      <fo:block text-indent="1em" space-before="4pt">私はガラスを食べられます。それは私を傷つけません
      </fo:block>
    </fo:block>
  </fo:block>
</fo:block>

produces #################### in the PDF. I'm aware of the issue: http://xmlgraphics.apache.org/fop/faq.html#pdf-characters

When I go under Document Properties->Fonts, the Helvetica font is listed with 'Encoding: ANSI'. Is there a way to change this?

If I were embedding, what would be the best way to do so without having access to Helvetica.ttf? I've tried using DejaVuSans, but I end up with squares in place of the # signs.

Note that this is not a one-time use from the command line (that would be a start), but an extension to an existing app. I'm trying to support UTF-8 characters without too much complexity.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜未央樱花落 2024-08-09 06:56:32

AFAICT,PDF 规范中包含的字体仅包含 ISO- 中的字符拉丁语-1。如果您想要的字符不属于附件 D:字符集和编码中定义的字符,那么您需要嵌入该字体。

AFAICT, the fonts included in the PDF specification only include characters from ISO-Latin-1. If you want a character that falls outside of those defined in Annex D: Character Sets and Encodings, then you are expected to embed the font.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文