I started recently to use PDFBox to process some PDF files. I loaded successfully the Roboto font, however, I don't understand the difference between PDType0Font, PDType1Font and PDTrueTypeFont. Which one is better to use?
Regards
If you want to use the standard 14 fonts (times, helvetica, courier, symbol, zapf dingbats) => use PDType1Font.HELVETICA etc. (Only WinAnsiEncoding supported)
If you have type1 fonts on your computer and want to use these => use the PDType1Font constructor.
If you want to use TrueType fonts in an inefficient way (only 256 glyphs, no subsetting) => use PDTrueTypeFont.load().
If you want to use TrueType fonts in an efficient way (more than 256 glyphs, subsetting) => use PDType0Font.load(). You can and should use the same font object for the whole PDF, i.e. don't create a new PDFont object for each page.
If you want to use TrueType collections, do this:
TrueTypeCollection ttc = new TrueTypeCollection(new File("C:/windows/fonts/mingliu.ttc"));
PDFont font = PDType0Font.load(doc, ttc.getFontByName("MingLiU"));
...
ttc.close(); // only after PDF has been saved
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With