【问题标题】:Can't get Indian Rupees symbol to show up in PDF generated with Flying Saucer无法在使用飞碟生成的 PDF 中显示印度卢比符号
【发布时间】:2019-05-29 01:24:50
【问题描述】:

我正在尝试几种不同的方法,但我无法获得使用 Flying Saucer 生成的 pdf(来自 html 文件)来显示印度卢比的 unicode 字符 -“₹”

这是我目前拥有的:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <style>
      body {
        font-family: Arial Unicode MS, Lucida Sans Unicode, Arial, verdana, arial, helvetica, sans-serif;
      }      

      @font-face {
        font-family: 'Arial Unicode MS';
        src: url(arialunicodems.ttf);
        -fs-pdf-font-embed: embed;
        -fs-pdf-font-encoding: UTF-8;
        -fs-pdf-font-encoding: Identity-H;
        font-weight: normal;
      }

    </style>

  </head>
  <body>

    <p>We want to see a Indian Rupees symbol between the asterisks on one or more of these lines, in the PDF (if any of the symbols make it through to the PDF then we're good):</p>
    <p>Using the glyph itself in the markup: * ₹ *</p>
    <p>Using &amp;#x20B9; in the markup: * &#x20B9; *</p>
    <p>Using &amp;#8377; in the markup: * &#8377; *</p>

  </body>
</html>

这代表了许多不同的实验,但都没有奏效。它所指的字体文件位于上述 html 文件版本的旁边。

字体本身似乎正在加载,因为 pdf 文件中的文本看起来像 Arial。它只是缺少卢比符号。我不知道还能做什么 - 我正在使用 unicode 字体,并且在浏览器中查看时,html 文件本身看起来很好。当我用 chrome 打印出来时,它看起来也很好,所以我认为问题肯定出在飞碟上。

我使用飞碟如下:

/usr/bin/java -Djava.awt.headless=true -cp .:$FS_PATH/acts_as_flying_saucer/lib/java/bin:$FS_PATH/acts_as_flying_saucer/lib/java/jar/minium.jar:$FS_PATH/acts_as_flying_saucer/lib/java/jar/itext-paulo-155.jar:$FS_PATH/acts_as_flying_saucer/lib/java/jar/core-renderer.jar:$FS_PATH/acts_as_flying_saucer/lib/java/jar/java-getopt-1.0.13.jar Xhtml2Pdf /home/max/font_test.html /home/max/font_test.pdf

谁能看看我做错了什么?

【问题讨论】:

    标签: pdf unicode utf-8 flying-saucer


    【解决方案1】:

    我在这里回答我自己的问题,以防其他人犯同样的错误。答案很简单——它不在字体中!事实证明,“₹”符号是在 2010 年才发明的,因此在很多 Unicode 字体文件中都不存在,包括我使用的那个。

    它可以在浏览器中运行,因为浏览器 (Chrome) 会自动在其他字符集中查找它(没有我明确要求它),并在 Deja Vu Sans 中找到它(Linux Chromium 的后备)。

    我更改了我的代码以使用旧的(但仍然可以接受)“₨”符号,但更合适的解决方法是包含一个实际上具有现代卢比符号的字体。

    【讨论】:

    • 谢谢。原来这也是我的问题。对于发现此 StackOverflow 页面的未来疑难解答者,我能够通过 Microsoft 的字体验证器运行该字体最终确定该字体缺少字符:github.com/microsoft/Font-Validator
    猜你喜欢
    • 1970-01-01
    • 2021-07-26
    • 1970-01-01
    • 2016-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    相关资源
    最近更新 更多