Why is iText embedding font even if I have specifi

2019-05-22 22:10发布

问题:

I am using Noto fonts to create pdf and looking embedding of a font vs not embedding them. 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_EMBED option still embed the font ?
  2. Since Noto fonts are open sourced by google and supported by adobe 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 ?

回答1:

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

Section 9.7.5.2:

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

Adobe owns a whole lot of patents with respect to PDF software. Adobe grants the right to any one to use these patents for free on condition that you create PDF files that are compliant with the PDF specification.

If you would tweak iText so that it would not embed fonts with Identity-H CMaps, you would be in violation with the PDF specification and that could bring about some patent violations too.



标签: fonts itext