I was trying to use EmbeddedFiles.Count (as below) to determine if a PDF file has attachments, but
the APi returns zero for a PDF with attachments.
Is there an (efficient) API to query if a PDF has file attachments?
The only thing I have found is to try and extract them as described at:
https://docs.aspose.com/pages/viewpage.action?pageId=7119730
but that seems inefficient
Sample code
// Create Blank Page Pdf
string pdfFileName = “CreateFileAnnotation.pdf”;
Document pdfDocument = new Document();
pdfDocument.Pages.Add();
pdfDocument.Save(pdfFileName);
// Modify the PDF to add a file attachment
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(pdfFileName);
editor.CreateFileAttachment(new System.Drawing.Rectangle(50, 50, 10, 10), "here", attachedPdf, 1, "Paperclip", 0.005);
editor.Save(pdfFileName+ ".out.pdf");
// Inspect PDF to determine if it has file attachments
pdfDocument = new Document(pdfFileName + ".out.pdf");
int embeddedFilesCount = pdfDocument.EmbeddedFiles.Count;
Console.WriteLine("The resulting PDF has EmbeddedFiles Count: " + embeddedFilesCount);