开发者

Preserving Embedded Fonts in iText

开发者 https://www.devze.com 2023-02-13 03:59 出处:网络
I have a java application which splits a pdf into sections using itext, then stitches a selection of these up t开发者_开发知识库ogether again.The original pdf has many embedded fonts varying in type (

I have a java application which splits a pdf into sections using itext, then stitches a selection of these up t开发者_开发知识库ogether again. The original pdf has many embedded fonts varying in type (all non-system fonts). When I stitch the pdf's up again, some of the embedded fonts are missing.

For example, this is a clipping from the original fonts list:

Preserving Embedded Fonts in iText

This is a clipping from the generated pdf font list:

Preserving Embedded Fonts in iText

I am using PdfWriter and PdfReader to copy the pages into the new document, with PdfContent and addTemplate().


Finally found the answer! The problem was the level of Pdf was set too low:

writer.setPdfVersion(PdfWriter.VERSION_1_2);

I changed this to:

writer.setPdfVersion(PdfWriter.VERSION_1_7);

and now all fonts are embedded correctly.

I actually forgot that piece of code was in there - I had borrowed it from a project I had done in the past.

Lesson learned ;)

I would love to know why this is the case though.

0

精彩评论

暂无评论...
验证码 换一张
取 消