Created
November 2, 2020 17:08
-
-
Save aspose-com-gists/7795776c555f43ff518d434bdb47133c to your computer and use it in GitHub Desktop.
Manipulate PDF Attachments using C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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