删除附件

删除所有附件

  1. 将源 PDF 绑定到 PdfContentEditor 对象。
  2. 调用 deleteAttachments() 删除所有嵌入的附件。
  3. 保存更新后的 PDF 文档。
public static void removeAttachments(Path inputFile, Path outputFile) {
    PdfContentEditor editor = new PdfContentEditor();
    try {
        editor.bindPdf(inputFile.toString());
        editor.deleteAttachments();
        editor.save(outputFile.toString());
    } finally {
        editor.close();
    }
}