使用 Apache FOP 2.4 生成 PDF 时获取 ###### 而不是表情符号

问题描述 投票:0回答:1

我正在使用 Apache FOP 2.4 的 Web 应用程序中生成 PDF。使用表情符号生成 PDF 时,生成的 PDF 格式为###############。但正常的字母数字文本显示正确。 以下是我的渲染器在 fop.xconf 文件中的样子。

<renderers>
    <renderer mime="application/pdf">
        <filterList>
            <value>flate</value>
        </filterList>
        <fonts>
            <font embed-url="ARIAL.TTF">
                <font-triplet name="Arial" style="normal" weight="normal"/>
            </font>
            <font embed-url="ARIALBD.TTF">
                <font-triplet name="Arial" style="normal" weight="bold"/>
            </font>
            <font embed-url="ARIALI.TTF">
                <font-triplet name="Arial" style="italic" weight="normal"/>
            </font>
            <font embed-url="ARIALBI.TTF">
                <font-triplet name="Arial" style="italic" weight="bold"/>
            </font>
            <font embed-url="ARIALUNI.TTF">
                <font-triplet name="Arial Unicode MS" style="normal" weight="normal"/>
            </font>
            <font embed-url="NotoColorEmoji-Regular.ttf">
                <font-triplet name="Noto Color Emoji" style="normal" weight="normal"/>
            </font>
            <font embed-url="MSGOTHIC.TTC" metrics-url="msgothic.xml">
                <font-triplet name="Gothic" style="normal" weight="normal"/>
                <font-triplet name="Gothic" style="normal" weight="bold"/>
                <font-triplet name="Gothic" style="italic" weight="normal"/>
                <font-triplet name="Gothic" style="italic" weight="bold"/>
            </font>
        </fonts>
    </renderer>
</renderers>

我添加了 NotoColorEmoji-Regular.ttf 以支持表情符号。但我仍然无法正确获取 PDF 中的表情符号。 我已将所有字体文件添加到与 fop.xconf 文件相同的级别。 我该如何解决这个表情符号问题?

java pdf-generation emoji apache-fop
1个回答
0
投票

我不相信 FOP 会支持它。该字体中的大多数字符都在 Supplementary Multilingual Plane 中。来自 FOP 文档:

“对基本多语言平面 (BMP) 之外的 Unicode 字符的支持,即代码点大于 65535 的字符,尚未实现。请参阅问题 FOP-1969。”

例如:

Unicode 字符“🐐” (U+1F410) = Unicode 1F410 = 128016

如果你在 Windows 机器上安装了那个字体并使用 charmap 查看它,你会发现可能只有 35 个字符。搜索一个显示没有字符:

如果你试图查看整个字体,你只会看到这些:

© www.soinside.com 2019 - 2024. All rights reserved.