Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Flying Saucer encoding problem

807580Feb 16 2008 — edited May 19 2010
Hi, i have a problem with encoding when creating pdf using Flying Saucer. I have xhtml document in UTF-8 and because I'm from the czech republic, i need to use several specific extended characters. The problem is, that Flying Saucer's default encoding is Latin1 (ISO-8859-1), which doesn't support these characters. In the documentation of the FS I have read that you can add specific fonts to support specific encoding by adding font to the font resolver of ITextRenderer class:

ITextRenderer renderer = new ITextRenderer();
FontResolver resolver = renderer.getFontResolver();
resolver.addFont (
"C:\\WINNT\\Fonts\\ARIALUNI.TTF",
BaseFont.IDENTITY_H,
BaseFont.NOT_EMBEDDED
);

where "C:\\WINNT\\Fonts\\ARIALUNI.TTF" is the font, "BaseFont.IDENTITY_H" specifies the encoding (in this case UTF-8) and "BaseFont.NOT_EMBEDDED" is another attribute, not important for now.

But even if I add the font this way, the FS still uses LATIN1 encoding and these characters are displayed wrong. Does anyone know, how to tell FS to use the UTF-8 encoding instead of the default one? Is there anything more I have to set? I was searching the internet and whole documentation for ages but wasn't able to find anything:( any help appreciated..thx
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2010
Added on Feb 16 2008
9 comments
15,105 views