XSL FO:使用法语、德语和意大利语字符的多语言 pdf [英] XSL FO : Multiple language pdf using french,German and Italian characters

查看:36
本文介绍了XSL FO:使用法语、德语和意大利语字符的多语言 pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用 FOP 1.1 jar.问题是这样的,当我在我的 xsl fo 模板中从法语中打印像Numéro de commande"这样的静态文本时,会出现奇怪的字符而不是é".我在 fo 根标签中使用了 base 14 的字体系列(Times Roman),但仍然出现这个问题.最后,请帮我解决这个问题.

解决方案

(发布 FO 文件的简短示例确实有助于找到精确的解决方案;否则,我们只能尝试猜测...)

提到奇怪的字符"而不是想要的字符指向编码问题;否则可能是字体配置问题.

如果您打开 FO 文件,重音字符是否按预期显示?

如果不是,则您的输入文件中存在编码问题,而 FOP 只是表现正常.
可能的原因和暂定解决方案:

  • FO 文件编码未设置或不正确:UTF-8 应该是一个安全的选择,因此在初始 xml 声明中尝试使用 encoding="UTF-8"
  • 也许有些文本被复制并粘贴到 FO 文件中,出现问题:尝试直接在 FO 文件中写入重音字符,并检查生成的 pdf 是否正确
  • 如果 FO 文件是由您的项目代码生成的,请检查您是否错误地将 unicode 字符串用作字符序列

FO 文件包含重音字符,但 PDF 显示的是#"?

那肯定是FOP字体配置有问题.请注意,如果您使用 Base-14 字体,则无需进行字体配置.

例如,这个简单的 FO 文件产生了一个正确的输出,没有任何配置,也没有任何字体相关的属性:

当您使用 font-family 属性设置的字体没有正确的字形时,PDF 中会出现字符#"(请参阅​​ http://xmlgraphics.apache.org/fop/1.1/fonts.html#missing-glyphs).>

所以:

I'm using FOP 1.1 jar in my project. Problem is like that, when i'm printing static text like "Numéro de commande" from french language in my xsl fo template, then strange characters are appearing instead of "é". I'm using font family(Times Roman) of base 14 in fo root tag but still this problem is occurring. In the end,Please help me to solve this issue.

解决方案

(posting a short example of your FO file could really help finding a precise solution; without that, we can only try to guess ...)

The mention of "strange characters" instead of the desired ones points towards an encoding problem; otherwise it could be a font configuration problem.

If you open the FO file, do the accented characters appear as expected?

If not, there is an enconding problem in your input file, and FOP is just behaving normally.
Possible causes and tentative solutions:

  • the FO file enconding is not set or not correct: UTF-8 should be a safe choice, so in the initial xml declaration try using encoding="UTF-8"
  • maybe some text was copied and pasted into the FO file, and something went wrong: try writing the accented characters directly in the FO file, and check if the produced pdf is correct
  • if the FO file is generated by your project code, check whether you are incorrectly using unicode strings as char sequences

The FO file contains the accented characters, but the PDF shows "#" instead?

Then it's definitely a problem with FOP fonts configuration. Note that font configuration is not necessary if you use Base-14 fonts.

For example, this simple FO file produces a correct output, without any configuration and without any font related property:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="one">
            <fo:region-body />
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="one">
        <fo:flow flow-name="xsl-region-body">
            <fo:block>à è ê é ì ò ù ç</fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

The character "#" appears in the PDF when the font you set with the font-family property does not have the right glyph (see http://xmlgraphics.apache.org/fop/1.1/fonts.html#missing-glyphs).

So:

这篇关于XSL FO:使用法语、德语和意大利语字符的多语言 pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆