XSL FO : Multiple language pdf using french,German and Italian characters

为君一笑 提交于 2019-12-08 04:07:15

问题


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.


回答1:


(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:

  • make sure you are really using one of the Base14 font families: see http://xmlgraphics.apache.org/fop/1.1/fonts.html#Base-14-Fonts
  • should you need to use a different font, make sure it has all the glyphs you need, and then configure it correctly: see http://xmlgraphics.apache.org/fop/1.1/configuration.html#renderers


来源:https://stackoverflow.com/questions/27774222/xsl-fo-multiple-language-pdf-using-french-german-and-italian-characters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!