使用 iText 将字体嵌入 PDF 文件 [英] Embed font into PDF file by using iText

查看:57
本文介绍了使用 iText 将字体嵌入 PDF 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定义了一个标签映射,并得到了一个 XML 数据文件.我想使用 iText 将 XML 数据文件转换为 PDF.问题是XML转PDF时如何将字体(如波兰字体、中文字体)嵌入到目标PDF中?

I defined a tag map, and got a XML data file. I want to convert the XML data file to PDF by using iText. The question is how to embed fonts (e.g. Polish font, Chinese font) into the target PDF when converting XML to PDF?

推荐答案

如果您正在使用 iText 做更多的工作,您可能想要投资于 iText book - 它有 iText 所有功能的例子.

If you are doing more work with iText, you may want to invest into the iText book - it has examples for all the features of iText.

您在创建定义字体嵌入的字体时指定了一个参数:

There is a parameter that you specify when you create your font that defines font embedding:

BaseFont helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
Font font = new Font(helvetica, 12, Font.NORMAL);

您可以在此处找到更多与 iText 字体相关的示例:http://1t3xt.info/examples/browse/?page=toc&id=14

You can find more iText font related examples here: http://1t3xt.info/examples/browse/?page=toc&id=14

这篇关于使用 iText 将字体嵌入 PDF 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆