使AcroFields(iTextSharp)不可编辑并设置为粗体 [英] Make AcroFields(iTextSharp) are non editable and set bold

查看:3597
本文介绍了使AcroFields(iTextSharp)不可编辑并设置为粗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iTextSharp将数据填充到PDF模板,这是在OpenOffice中创建的。
它填充得很好,我得到了正确的PDF,但那是可编辑的模式。我想要不可编辑的PDF 。并且还某些行BOLD(按程序)。下面是我的代码段。

I'm using iTextSharp to populate the data to PDF Templates, which is created in OpenOffice. it populating fine, I'm getting proper PDF, But that is coming editable mode. I want non-editable PDF. And also make some rows BOLD( by Program). below is my snippet code.

PdfStamper stamper = new PdfStamper(reader, outputStream);
AcroFields fields = stamper.getAcroFields();
//loop
fields.setField("Desc_", "HILINSKI, MARK");

请帮帮我。
谢谢。

Please help me. Thanks.

推荐答案

如果您不希望表格可编辑,请使用表单拼接,如下所示 FillDataSheet 示例。将其添加到您的代码中:

If you don't want to form to be editable, use form flattening as is done in the FillDataSheet example. Add this to your code:

fields.setGenerateAppearances(true);
stamper.setFormFlattening(true);

如果要更改特定字段的字体,请使用 setFieldProperty( )更改textfont的方法,如 TextFieldFonts 示例:

If you want to change the font of specific fields, use the setFieldProperty() method to change the "textfont" as is done in the TextFieldFonts example:

BaseFont bold =
        BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
form.setFieldProperty("Desc_", "textfont", bold, null);

欲了解更多信息,请阅读官方文档

For more info, read the official documentation.

这篇关于使AcroFields(iTextSharp)不可编辑并设置为粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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