U+0151 ('odblacute') is not available in t

2019-07-18 14:55发布

问题:

I'm trying to set some text ( classical Hungarian dummy: árvíztűrő tükörfúrógép ):

contentStream.showText(text);

method with PDFBOX 2.0.7,and i got

U+0151 ('odblacute') is not available in this font Times-Roman encoding: WinAnsiEncoding

for őűŐŰ characters with all PDType1Font types. Other accented characters are working. Can anyone help me? Thanx a lot!

回答1:

Well yes, "ő" is not available in WinAnsiEncoding. As explained in the FAQ: to see what WinAnsiEncoding is, look at the PDF Specification Appendix D. If the character is available in your chosen font (in windows, have a look with charmap.exe), then load the font like this:

PDFont font = PDType0Font.load(document, new File("c:/windows/fonts/times.ttf"));

see also the EmbeddedFonts.java example in the source code download.



标签: pdfbox