1

I was wondering what steps were needed to render Asian characters using the java based xhtmlrenderer (flying saucer) library?

I am wanting to render the following:

<html>
    <body>同名の映画のモデ</body>
</html>

Without any font settings being added to the HTML this renders fine in normal browsers, but I can't find anyway to render this to PDF using the iTextRenderer portion of xhtmlrenderer.

After following various threads on the mailing list, I see lots of posts talking about adding .TTF files from the c:\windows\fonts directory, and I have modified the examples to run on linux ( https://gist.github.com/643173745182c9becc57 ), which shows me various fonts being displayed, but I don't see any Asian glyffs.

Does anyone have any decent pointers, or clean solutions to this problem? Or am I looking at the wrong problem with a really simple solution elsewhere?

Mark Derricutt
  • 979
  • 1
  • 11
  • 20
  • I've never used Flying Saucer so I'm not replying as an answer, but usually this kind of thing involves adding fonts to the renderer. Browsers are usually smart enough to detect it, but most of these libraries don't bother trying to find a suitable font. (BIRT for example is terrible at this). – Malaxeur Nov 08 '09 at 22:27
  • Thanks - I'm discovering this as well, have since found even more example flying saucer code showing the browser component displaying the glyffs on screen, but which still fail to render on PDF using iText. – Mark Derricutt Nov 08 '09 at 22:58

2 Answers2

1

You can also add the font style information in css.

@font-face {
    font-family: 'your_font_face_name';
    src: url('your_font.ttf');

    -fs-pdf-font-embed: embed;
    -fs-pdf-font-encoding: Identity-H;
        }
John
  • 541
  • 3
  • 6
  • 19
0

To support the big character set you need to specify a font file that has all those characters in it. Once you've picked a font file you'll need your application to point to that file. I've found that just putting the font files in your font's directory doesn't work.

Try embedding the font too, eg.

renderer.getFontResolver().addFont("your_font_file.ttf", BaseFont.EMBEDDED);

This link has quite a few font files.

anger
  • 1,018
  • 1
  • 9
  • 25