Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created November 2, 2020 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/7795776c555f43ff518d434bdb47133c to your computer and use it in GitHub Desktop.
Save aspose-com-gists/7795776c555f43ff518d434bdb47133c to your computer and use it in GitHub Desktop.
Manipulate PDF Attachments using C++
// Load attachment
SharedPtr<FileSpecification> fileSpecification = MakeObject<FileSpecification>(u"Attachment.txt", u"Sample text file");
// Add attachment to document's attachment collection
auto doc = MakeObject<Document>(u"Document.pdf");
doc->get_EmbeddedFiles()->Add(fileSpecification);
// Save PDF
doc->Save(u"..\\Data\\Attachments\\Attachment.pdf");
// Open document
auto doc = MakeObject<Document>(u"Document.pdf");
// Delete all attachments
doc->get_EmbeddedFiles()->Delete();
// Save updated file
doc->Save(u"Updated_Document.pdf");
// Open document
auto doc = MakeObject<Document>(u"Document.pdf");
// Get particular embedded file
SharedPtr<FileSpecification> fileSpecification = doc->get_EmbeddedFiles()->idx_get(1);
// Get the file properties
Console::WriteLine(u"Name: {0}", fileSpecification->get_Name());
Console::WriteLine(u"Description: {0}", fileSpecification->get_Description());
Console::WriteLine(u"Mime Type: {0}", fileSpecification->get_MIMEType());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment