Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Apr 26, 2021 4:24 pm

I am using FreeSpire.
My 1 page pdf document has 2 attachments; each are 4 pages.
//Create a pdf document.
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(inputFilespec);
int ctrAttachments = doc.Attachments.Count;

ctrAttachments should be 2 but it is zero.

kensmith38
 
Posts: 9
Joined: Sun Oct 12, 2014 6:01 pm

Tue Apr 27, 2021 3:16 am

Hello,

Thank you for your inquiry.
Since you did not provide PDF file, I simulated a file and use the code you provided to have a test, but didn't replicate your problem. To help us investigate and solve your problem more quickly and accurately, please provide your input PDF file. You could attach it here or send to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1651
Joined: Wed Apr 07, 2021 2:50 am

Tue Apr 27, 2021 4:38 pm

I wish I could send the document (with its embedded attachments, but the document and attachments contain private medical information.
Maybe these clues will help.
Here are some of the objects from the raw pdf data of the main document which contains the two attachments.
3 0 obj
<</CreationDate(D:20210324134428-05'00')
/Creator(Acrobat PDFMaker 21 for Microsoft Outlook)
/MailAttachments(31251_Peer_Report.pdf 31251_MedicalProvider_Notification Letter.pdf ) <--- Note that these are the 2 attachments
/MailCC(REDACTED@REDACTED.com REDACTED )
/MailDate(D:20210324134300-05'00')/MailFolder(Sent Items)
/MailFrom(REDACTED@REDACTED.com REDACTED)
/MailSubject( REDACTED Peer Review Determination)
/MailTo(REDACTED@fax2mail.com REDACTED@fax2mail.com )
/ModDate(D:20210324134429-05'00')/Producer(Adobe PDF Library 21.1.167)>>
endobj
43 0 obj
<</Filter[/FlateDecode]/Length 77980/Params<</Size 80450>>/Subtype/application#2Facrobat/Type/EmbeddedFile>>stream
endobj
46 0 obj
<</Filter[/FlateDecode]/Length 162680/Params<</Size 167266>>/Subtype/application#2Facrobat/Type/EmbeddedFile>>stream
endobj

kensmith38
 
Posts: 9
Joined: Sun Oct 12, 2014 6:01 pm

Wed Apr 28, 2021 3:35 am

Hi,

Thank you for your feedback.
Since you were using our Free Spire.PDF, I firstly recommend that you try the latest commercial edition Spire.PDF Pack(Hot Fix) Version:7.4.13 as it is more stable and stronger than the free one. If the issue still exists after trying, please provide your input PDF file. Don't worry, we promise to keep your document confidential and we will not use it for any other purpose. Besides, you could remove the security data of your document or make a sample PDF as long as it could reproduce your issue. Please send it to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1651
Joined: Wed Apr 07, 2021 2:50 am

Thu May 06, 2021 1:59 pm

I appreciate all the suggestions. I can't send the file because it would violate HIPAA rules. I have been tempted to try the commercial version (rather than the Free version) but I don't want to corrupt my Build Environment. I don't know if I can acquire the commercial version on a trial basis, and then somehow revert back to my Free version. I use a lot of Adobe Acrobat Interapplication Communication in my application. There are a few situations where I use the Free SpirePDF for small 3 page documents. I think SpirePDF is amazing.
It isn't fair for me to keep the ticket open so feel free to close the ticket. If I eventually test the commercial version, I will let you know the results.

P.S. I created a PDF with attachments and Free SpirePDF successfully recognized the attachments. The problem document was created by Outlook (or some add-in of Outlook); I am not able to duplicate that scenario. Opening that document with Adobe Acrobat displays the attachments so I suspect the document is not corrupted.

kensmith38
 
Posts: 9
Joined: Sun Oct 12, 2014 6:01 pm

Fri May 07, 2021 6:08 am

Hello,

Thank you for your feedback.
I simulated a PDF file that was converted from Outlook to test your case, indeed reproduced the same problem as yours. I have recorded it in our bug tracking system with the ticket number SPIREPDF-4277, our development team will investigate and fix it. Once it is resolved, we will provide a commercial version with fix for you. In addition, our sales team has sent a temporary license (one month free) to your email for trial.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1651
Joined: Wed Apr 07, 2021 2:50 am

Mon May 17, 2021 9:52 am

Hello,

Thanks for your patient waiting.
After further investigation, we found that the attachments in the PDF file that was converted from Outlook are in the form of annotation attachments. You could get the correct count by obtaining the annotation attachments. Please refer to the code below. If you still have problems, please provide your sample PDF document.

Code: Select all
            PdfDocument document = new PdfDocument();
            document.LoadFromFile(inputFilespec);

            //Instantiate a list to which the Attachment annotations of all pages in the document will be added
            List<PdfAttachmentAnnotationWidget> attaches = new List<PdfAttachmentAnnotationWidget>();
            foreach (PdfPageBase page in document.Pages)
            {
                foreach (PdfAnnotation annotation in page.AnnotationsWidget)
                {
                    if ((annotation as PdfAttachmentAnnotationWidget) != null)
                    {
                        attaches.Add(annotation as PdfAttachmentAnnotationWidget);
                    }
                }
            }
            int ctrAttachments = attaches.Count;

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1651
Joined: Wed Apr 07, 2021 2:50 am

Fri May 21, 2021 8:27 am

Hello,

Greetings from e-iceblue.
How is your issue going? Has it been resolved? If not, please provide your sample PDF document to help us do further investigation. Thanks in advance.

Sincerely
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1651
Joined: Wed Apr 07, 2021 2:50 am

Fri May 21, 2021 12:50 pm

I would like to thank you, Annika, for all of your help; you went above and beyond the amount of assistance that I expected.
I have confirmed your latest code recommendation (look for annotation attachments). You duplicated my scenario (creating a PDF from an Outlook email which had attachments in the email) and you provided the exact code snippet to count those annotation attachments. We should consider this issue to be resolved.
Thanks for all of your help.
Sincerely,
Ken Smith

kensmith38
 
Posts: 9
Joined: Sun Oct 12, 2014 6:01 pm

Mon May 24, 2021 1:28 am

Hello,

You are welcome.
If you have other questions about using Spire.PDF in the future, please feel free to contact us.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1651
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF