Get Attachments from a PDF Document doesnt't work?

Hi, i try to get attachments from a file using aspose-pdf-4.2.0.jar, but i don't find any file inside the pdf.

In Attachment there is a test class with a pdf file.

Thanks in advance,
Marco

Hi Marco,

We are sorry for the inconvenience faced. While testing the scenario with Aspose.Pdf for Java 4.2.1, we’ve managed to reproduce the issue on our side and logged it in our bug tracking system as PDFNEWJAVA-33743 for further investigation and resolution. We’ll notify you as soon as it’s resolved.

Please feel free to contact us for any further assistance.

Best Regards,

Hi Marco,


Thanks for your patience. We’ve further investigated and found that attachment in your source document are attached as annotation. Please check following code snippet to get attachment. Hopefully it will help you to accomplish your requirements.

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(myDir+“fileWithAtt.pdf”);
if (pdfDocument.getEmbeddedFiles().size() != 0)
{
//get particular embedded file
com.aspose.pdf.FileSpecification fileSpecification = pdfDocument.getEmbeddedFiles().get_Item(2);
//get the file properties
System.out.printf(“Name: - " + fileSpecification.getName());
System.out.printf(”\nDescription: - " + fileSpecification.getDescription());
System.out.printf("\nMime Type: - " + fileSpecification.getMIMEType());
}
else if (pdfDocument.getPages().get_Item(1).getAnnotations().size() != 0)
{
Annotation annotation = pdfDocument.getPages().get_Item(1).getAnnotations().get_Item(2);
if (annotation instanceof FileAttachmentAnnotation)
{
FileSpecification file = ((FileAttachmentAnnotation) annotation).getFile();
if (file != null && file.getName() != null)
{
System.out.printf(“Name: - " + file.getName());
System.out.printf(”\nDescription: - "
+ file.getDescription());
System.out.printf("\nMime Type: - "
+ file.getMIMEType());
}
}
}

Please feel free to contact us for any further assistance.

Best Regards,