Make AcroFields(iTextSharp) are non editable and set bold

a 夏天 提交于 2019-12-07 20:54:15

问题


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.


回答1:


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);

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.



来源:https://stackoverflow.com/questions/24282559/make-acrofieldsitextsharp-are-non-editable-and-set-bold

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!