iText pdf library
Website search

Why is iText embedding a font even when I specify not to embed?

I am using Noto fonts to create a PDF and evaluating embedding versus not embedding. This is my code:


FontFactory.register("c:/temp/fonts/NotoSansCJKsc-Regular.otf", "my_nato_font");
Font myBoldFont = FontFactory.getFont("my_nato_font", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
When I create the pdf and do a CTRL + D, I can see that the fonts have been embedded.

However once I go with option:


FontFactory.register("c:/temp/fonts/NotoSansCJKsc-Regular.otf", "my_nato_font");
Font myBoldFont = FontFactory.getFont("my_nato_font");
The size of file is reduced and the fonts are not embedded. Now I cannot see the Chinese characters which I have added to the PDF.

My questions

  1. Why does NOT_EMBEDDED option still embed the font ?
  2. Since Noto fonts are open sourced by google and supported by adobe (see Introducing Source Hans), I would assume that end user should be able to view the documents even with out the need to embed them. Is my understanding wrong?

Posted on StackOverflow on Mar 26, 2015 by vsingh

You are using Identity-H. In that case, the font shall be embedded. If the embedded parameter wouldn't be ignored, iText would be creating a PDF that is in violation with ISO-32000-1:


The Identity-H and Identity-V CMaps shall not be used with a non-embedded font.

By ignoring your NOT_EMBEDDED setting, iText is protecting you from creating a PDF that isn't correct.

As for your second example: you are getting the font from the font factory using the default encoding. This encoding doesn't support Chinese characters.

Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now