pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose M. Sanchez" <jose.sanc...@swissrisk.com>
Subject UTF-8 encoded fonts
Date Mon, 23 Jan 2012 12:48:18 GMT
Hi all,

I am trying to find out a way to write Cyrillic characters to a PDF 
document, is this supported by pdfbox?

My last test was to download a font (the gentium font from 
http://scripts.sil.org/cms/scripts/page.php?item_id=Gentium, which is 
UTF-8 encoded) and try to load it, but I get the following exception:

Exception in thread "main" java.io.IOException: Invalid Characters codes
     at 
org.apache.fontbox.ttf.CMAPEncodingEntry.processSubtype12(CMAPEncodingEntry.java:218)
     at 
org.apache.fontbox.ttf.CMAPEncodingEntry.initSubtable(CMAPEncodingEntry.java:97)
     at org.apache.fontbox.ttf.CMAPTable.initData(CMAPTable.java:90)
     at 
org.apache.fontbox.ttf.AbstractTTFParser.parseTables(AbstractTTFParser.java:163)
     at org.apache.fontbox.ttf.TTFParser.parseTables(TTFParser.java:61)
     at 
org.apache.fontbox.ttf.AbstractTTFParser.parseTTF(AbstractTTFParser.java:90)
     at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:26)
     at 
org.apache.fontbox.ttf.AbstractTTFParser.parseTTF(AbstractTTFParser.java:66)
     at org.apache.fontbox.ttf.TTFParser.parseTTF(TTFParser.java:26)
     at 
org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:204)
     at 
org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:164)
     at 
org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:140)
     at 
org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:127)

This is the code:

[...]
          String fontfile = 
"C:/jms/tmp/ttf/GentiumPlus-1.508/GentiumPlus-R.ttf";
          doc = new PDDocument();
          PDPage page = new PDPage();
          doc.addPage(page);
          PDFont font = PDTrueTypeFont.loadTTF(doc, fontfile);
[...]

Is there a way to write Cyrillic characters using PDF Box?

Thanks in advance,

Jose M. Sánchez

Mime
View raw message