3

I’m attempting to write text to a PDF in situations where I need to support multiple languages on a single PDF. This may include regular latin characters as well as CJK characters. I’ve tried many attempts to do this and have it load the character sets from the OS without much success. The farthest I have gotten is support latin characters, arabic, russian and I believe Vietnamese characters found on the embedded fonts example here https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFonts.java?view=markup

I’m doing a similar approach from the example but I believe I’m using the FileSystemFontProvider provided by the FontMappers class by doing something such as

TrueTypeFont ttf = FontMappers.instance().getTrueTypeFont("Arial", null).getFont();
PDFont font = PDType0Font.load(signatureDocument, ttf.getOriginalData());

As I mentioned I seem to be able to support the text in the EmbeddedFonts example but can’t seem to determine how I can also support CJK. When I try to print characters from chinese, japanese or korean it throws an IllegalArgumentException: No glyph for U+ in the font ArialMT.

I’m currently using 2.0.2 of PDFBox but could potentially upgrade to 2.0.3 if that would help at all.

Dan King
  • 1,080
  • 1
  • 11
  • 28
  • I suspect you require a heuristic way of finding the right font, given the aggregation of languages you intend to display in your pdf (some simple google search *might* help there). You may also end up using multiple content streams and different fonts in the same file - see [here](https://pdfbox.apache.org/1.8/cookbook/workingwithfonts.html) for some literature. – Mena Oct 12 '16 at 12:33
  • 1
    Try the batang.ttc font. How to use ttc fonts, see here: https://stackoverflow.com/questions/33044069/pdfbox-2-0-and-ttc-fonts – Tilman Hausherr Oct 12 '16 at 20:14
  • Are operating system's packaged or have TTC files available on them? Also, how would we reference a TTC file in a platform independent way? – Dan King Oct 13 '16 at 18:24
  • Dan King did you get a solution for your question? If so, please let me know. Please answer your own question, I'm curious for your solution. – Bodo Oct 26 '17 at 09:09

0 Answers0