Gurpreet Singh
Gurpreet Singh

Reputation: 11

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

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.

Upvotes: 1

Views: 1488

Answers (1)

lfurini
lfurini

Reputation: 3788

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

Upvotes: 1

Related Questions