问题
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