Supprimer les pièces jointes

Supprimer toutes les pièces jointes

  1. Liez le PDF source à la façade PdfContentEditor.

  2. Appelez deleteAttachments() pour supprimer toutes les pièces jointes intégrées.

  3. Enregistrez le document PDF mis à jour.

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();
    }
}