Hello ASPOSE,
I tried the code provided at http://www.aspose.com/docs/display/pdfnet/Get+All+Attachments+from+a+PDF+Document
But no attachment was found even I can see the attachment in Adobe.
The PDF was formerly created with Acrobat PDFMaker 22 tool.
Please tell me how I can access the attachment correctly.
Regards
Rusty
PS: the code I used
// Open document
Document pdfDocument = new Document(@“c:\temp\DownloadablesWithAttachmentsTest.pdf”);
// Get embedded files collection
EmbeddedFileCollection embeddedFiles = pdfDocument.EmbeddedFiles;
// Get count of the embedded files
Console.WriteLine(“Total files : {0}”, embeddedFiles.Count);
// Loop through the collection to get all the attachments
foreach (FileSpecification fileSpecification in embeddedFiles)
{
Console.WriteLine(“Name: {0}”, fileSpecification.Name);
Console.WriteLine(“Description: {0}”, fileSpecification.Description);
Console.WriteLine(“Mime Type: {0}”, fileSpecification.MIMEType);
// Check if parameter object contains the parameters
if (fileSpecification.Params != null)
{
Console.WriteLine(“CheckSum: {0}”, fileSpecification.Params.CheckSum);
Console.WriteLine(“Creation Date: {0}”, fileSpecification.Params.CreationDate);
Console.WriteLine(“Modification Date: {0}”, fileSpecification.Params.ModDate);
Console.WriteLine(“Size: {0}”, fileSpecification.Params.Size);
}
// Get the attachment and write to file or stream
byte[] fileContent = new byte[fileSpecification.Contents.Length];
fileSpecification.Contents.Read(fileContent, 0, fileContent.Length);
FileStream fileStream = new FileStream(fileSpecification.Name, FileMode.Create);
fileStream.Write(fileContent, 0, fileContent.Length);
fileStream.Close();
}