I am trying to create a pdf using openPDF. If I try to print certain characters like Ą (U+0104) they are not shown on the pdf which is produced.
I have set the Chunk font to Times New Roman using a .ttf file. This file was taken from my system (I know I may need to work out licensing issues later), and I know it has a character for Ą.
FontFactory.register("font/system-times-new-roman.ttf", "custom");
Font font = FontFactory.getFont("custom");
Chunk chunk = new Chunk("Value to Print", font);
I can tell this is succesfully setting the font to Times New Roman, but not why it isn't showing some characters. I get the same if I set it using:
Font font = FontFactory.getFont("Times-Roman")
If I set the font to:
Font font = FontFactory.getFont("defaultEmbedded")
Then it shows the character, but not in a serif font. Has anyone come across this before? I could try using another pdf generator tool, but would require a lot of rework.
As mentioned in the link K J sent, the issue is that the multi-byte characters were not showing. To enable them I added the Apache dependencies:
I then updated the getFont call with this:
FontFactory.getFont("custom", "Identity-H", false, 10, 0, null)));Now multi byte characters are displaying correctly in Times New Roman.