Removing attachment from PDF
Contents
[
Hide
]
Aspose.PDF can remove attachments from PDF files. A PDF document’s attachments are held in the Document object’s EmbeddedFiles collection.
To delete all attachments associated with a PDF file:
- Call the EmbeddedFiles collection’s Delete method.
- Save the updated file using the Document object’s Save method.
The following code snippet shows how to remove attachments from a PDF document.
void WorkingWithAttachments::RemovingAttachment() {
String _dataDir("C:\\Samples\\");
// Open document
auto pdfDocument = new Document(_dataDir + u"DeleteAllAttachments.pdf");
// Delete all attachments
pdfDocument->get_EmbeddedFiles()->Delete();
// Save updated file
pdfDocument->Save(_dataDir + u"DeleteAllAttachments_out.pdf");
}