Reputation: 2355
I need to embed all fonts in my pdf using velocity and ITextRenderer in Java.
Most of the fonts works without problem like
renderer.getFontResolver().addFont(
getClass().getResource("fonts/tahoma.ttf").toExternalForm(), true);
I have the same code for Times-Roman and Helvetica, but the generated pdf doesn't have these 2 embedded. I made sure the name of the font matches the name of the missing font in the property of the PDF file.
Upvotes: 2
Views: 2455
Reputation: 77576
Flying Saucer is a product built on top of iText. Although the iText companies don't endorse the use of Flying Saucer, I'll make an exception and answer this question (I'm the CEO of iText Software).
You are referring to fonts that used to be known as the Base 14 fonts. Today, these fonts are called the Standard Type 1 fonts.
As opposed to TrueType and OpenType fonts, Type 1 fonts are described in a set of two files. Each font has:
As defined in the PDF specification, every viewer should be able to render the 14 Standard Type 1 fonts. That is why people usually don't embed them (unless there are specific reasons to embed the font. PDF/A compliance is one of those reasons).
As for iText, iText ships with 14 AFM files. iText can do so, because the license for the AFM files permits this. iText does not ship with the corresponding PFB files. If it did, that would be illegal because the PFB files aren't available for free. As a result, iText will never embed the 14 Standard Type 1 fonts, even if you set the embedded
parameter to true
. The only way to embed fonts such as Helvetica, is by providing a font program. That is: not merely the AFM file that ships with iText, but also the PFB file that knows how to draw the glyphs.
Be very careful when using Flying Saucer: if you use it in combination with iText 2, then this applies: https://stackoverflow.com/questions/25696851/can-itext-2-1-7-or-earlier-can-be-used-commercially If you are using it in combination with iText 5, then you may need a commercial license if you are not distributing your own code under the AGPL.
Upvotes: 5
Reputation: 201497
From Acrobat Help
A font can be embedded only if it contains a setting by the font vendor that permits it to be embedded.
The other fonts (that aren't working) don't permit embedding.
Upvotes: 2