I have noted a problem when working with the Spire.PDF attachments.
On some PDFs the attachments are added properly, but cannot be received afterwards via the Spire.PDF API.
For testing purpose I have created the following simple code example:
- Code: Select all
// Load the PDF.
PdfDocument document = new PdfDocument();
document.LoadFromFile("Document.pdf");
// Add png image as attachment.
PdfAttachment attachment = new PdfAttachment("Wikipedia_Science.png");
attachment.MimeType = "image/png";
attachment.Description = "Attached image.";
document.Attachments.Add(attachment);
// Check attachments.
int count = document.Attachments.Count; // Works fine. returns 1.
// Save pdf document.
string fileName = "DocumentWithAttachment.pdf";
document.SaveToFile(fileNameNew);
document.Close();
// Load the saved document and check attachments.
document.LoadFromFile(fileName);
count = document.Attachments.Count; // Does not work. returns 0.
document.Close();
Attaching the png image itself seems to work fine.
I can see and save the attachment, when opening the PDF with Adobe Acrobat DC.
But when I open the saved PDF with Spire.PDF and try to get the attachments, it is returning nothing.
Could you please invastigate what's the problem with this specific PDF.
Is this a known issue and are there any workarounds or fixes?
PS: I have also tested it with the latest hotfix 4.2.4(2018-02-09).
Best regards and thanks in advance
TSE