Remove Attachments

Remove all attachments

  1. Bind the source PDF to the PdfContentEditor facade.
  2. Call deleteAttachments() to remove every embedded attachment.
  3. Save the updated PDF document.
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();
    }
}