在生成的pdf报告中显示字符SQUARE M SQUARED(\ u33a1)

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

我正在使用以下代码为jasper pdf报告显示字符M SQUARED(\ u33a1)

<?xml version="1.0" encoding="UTF-8"?> 
...

<textField isStretchWithOverflow="true">
            <reportElement x="0" y="0" width="609" height="20" uuid="df8665ef-2226-4aaa-bd04-09805582eaef"/>
            <textElement verticalAlignment="Middle">
                <font fontName="SomeCustFont" size="20" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA["Squared M : \u33a1"]]></textFieldExpression>
        </textField>

对于此代码,我无法在PDF中看到unicode字符。它只是空白。但在XLSX中,我能够看到角色。我试过以下:

  1. 删除pdfEncoding
  2. 设置isPdfEmbedded =“false”

但没有运气

更新:似乎,我使用的自定义字体不支持平方m字符。我无法添加新字体或更新现有的自定义字体。但我可以为该特定字符使用任何或内置字体。如何使用内置字体实现此目的?

我试过了:

fontName =“Courier”pdfFontName =“Courier”jasper的内置字体支持该字符,但由于无法找到字体,因此收到错误。

utf-8 jasper-reports export-to-pdf
1个回答
0
投票

这里的主要问题是\ u33a1是一个扩展的ASCII unicode。大多数免费字体不支持此功能。因此,使用英文'm'字符,然后使用上标2 unicode \ u00b2而不是这个平方m,几乎所有字体都可以使用。

\ u33a1 - > m \ u00b2

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