Hi,
Hi Richard,
Moreover in reference to license, please note Aspose.Pdf
evaluation version has two limitations, evaluation watermark and at most
four elements of any collection can be viewed. You may request for a 30
days temporary license to evaluate our product without
any limitation.
Best Regards,
Hi Richard,
Thanks for sharing the source document. While testing the scenario with the latest version of Aspose.Pdf for Java 9.3.1, we have managed to reproduce the reported issue and logged it in our bug tracking system as PDFNEWJAVA-34397 for further investigation and resolution. We will notify you via this thread as soon as it is resolved.
We are sorry for the inconvenience caused.
Best Regards,
Hi Ahmad,
Hi Richard,
I saw your post and thought to share my code which I use to extract attachments. I am not sure if this is going to be helpfull for you, but I hope it helps.
Form pdfForm = new Form();
ByteArrayOutputStream out = new ByteArrayOutputStream();
pdfForm.bindPdf(PDF_FILE);
//get attachment
com.aspose.pdf.FileSpecification fileSpecification = pdfForm.getDocument().getEmbeddedFiles().get_Item(1);
//retrieve the contents of the attachment.
InputStream input = fileSpecification.getContents();
//Storing the Attached File Name.
String fileName = pdfForm.getDocument().getEmbeddedFiles().get_Item(1).getName();
//Deleting the existing attachment.
pdfForm.getDocument().getEmbeddedFiles().delete(fileName);
//Loading the attachment in a new pdf and flattening it.
com.aspose.pdf.Document obj = new com.aspose.pdf.Document(input);
Thanks
Rajeev
Hi Rajeev,
Hi Rajeev,
Hi Richard,
Hi Richard,
com.aspose.pdf.Document pdfDocument = new
com.aspose.pdf.Document(myDir + “Aspose attached Mail
document.pdf”);<o:p></o:p>
if (pdfDocument.getEmbeddedFiles().size() != 0)
{
//get particular embedded file
com.aspose.pdf.FileSpecification fileSpecification = pdfDocument.getEmbeddedFiles().get_Item(0);
//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)
{
Page page = pdfDocument.getPages().get_Item(1);
//let's look for all the annotations
for (Annotation annotation : (Iterable) page.getAnnotations())
{
//Annotation annotation = pdfDocument.getPages().get_Item(1).getAnnotations().get_Item(2);//The fileAttachment is third
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());
InputStream is = file.getContents();
byte[] buffer = new byte[is.available()];
System.out.printf("\navailable bytes: - " + buffer.length);
is.read(buffer);
OutputStream os = new FileOutputStream(myDir + file.getName());
os.write(buffer);
os.close();
}
}
}