【发布时间】:2015-05-15 03:28:07
【问题描述】:
我正在尝试读取 PDF 文件,然后在此过程中禁用签名字段。
PDDocument pdDoc = null;
try {
final int FLAG_READ_ONLY = 1;
File file = new File("C:/sample.pdf");
InputStream is = new FileInputStream(file);
pdDoc = PDDocument.load(is);
PDDocumentCatalog catalog = pdDoc.getDocumentCatalog();
PDAcroForm form = catalog.getAcroForm();
List<PDField> acroFormFields = form.getFields();
for (PDField field: acroFormFields) {
if (field.getFieldType().equalsIgnoreCase("Sig")) {
field.getFullyQualifiedName();
field.setReadonly(true);
field.getDictionary().setInt("FF", FLAG_READ_ONLY);
}
}
if (pdDoc != null) {
pdDoc.close();
}
}
我的问题:
- 我如何知道此禁用是否有效?因为,当我打开 PDF 我仍然可以在文件上签名。
-
field.getDictionary().setInt("FF", FLAG_READ_ONLY);我没有看到标志值Ff,所以我应该使用哪个标志。文档说FLAG_READ_ONLY- 一个Ff标志here。
【问题讨论】: