【发布时间】:2019-04-01 20:29:31
【问题描述】:
我正在使用removeField 删除文档的字段,但我如何才能完全删除 pdf 中的 acroform? 我知道
acroform.flatten()
但我想知道这是否是删除所有 acroform 的正确方法?有没有更好的方法可以使pdf尺寸变小?还是更快地删除 acroform?
【问题讨论】:
标签: pdfbox
我正在使用removeField 删除文档的字段,但我如何才能完全删除 pdf 中的 acroform? 我知道
acroform.flatten()
但我想知道这是否是删除所有 acroform 的正确方法?有没有更好的方法可以使pdf尺寸变小?还是更快地删除 acroform?
【问题讨论】:
标签: pdfbox
调用PDDocument.getDocumentCatalog().setAcroForm(null) 并从每个页面中删除所有小部件注释:
List<PDAnnotation> annotations = page.getAnnotations();
List<PDAnnotation> newList = new ArrayList<>();
for (PDAnnotation ann : annotations)
{
if (!(ann instanceof PDAnnotationWidget))
{
newList.add(ann);
}
}
if (newList.isEmpty())
{
page.setAnnotations(null);
}
else
{
page.setAnnotations(newList);
}
【讨论】:
page.setAnnotations(newList);吗?