Reputation: 557
I'm trying to write to a PDF in Webdings font using PDFBox. What I'd like to appear is the symbol that is represented by character A in Webdings. However, I get an IllegalArgumentException saying that there's no glyph in my Font for the given character. Am I missing something around encoding or is Webdings simply not supported?
I use PDFBox 2.0.17, many solutions to similar problems seem outdated. I can verify Webdings in the Character Map tool and it works in programs such as word. The actual problem I have is not with Webdings but another non-public font and I don't have any alternatives to that one. Using Webdings as the problem pattern seems to be the same.
PDFont font = PDFontType0Font.load(doc, new File("pathToWebdings.ttf"));
PDPageContentStream cos = new PDPageContentStream(doc, page, AppendMode.APPEND, true);
PDStreamUtils.write(cos,"a", font, 100, 100, 100, Color.BLACK);
cos.close();
java.lang.IllegalArgumentException: No glyph for U+0061 (a) in font Webdings
Upvotes: 0
Views: 3230
Reputation: 18851
I looked at it with DTL OTMaster 3.7 light (this is free and very useful), the checkmark will work with \uf061
with the webdings
font (tested in Windows 10).
(screenshot looks a bit weird because I have a 4K monitor)
Alternatively, use PDType1Font.ZAPF_DINGBATS
and then \u2714
will also work.
Upvotes: 1