Hi Rudy,
Hi Rudy,
Thanks for your feedback.
rmenjivar:
When I run the “GetAllAnnotationsFromPage” example, it finds the attachment link. But I don’t know where to go from there.
It seems that the document from which you are trying to get attachment has FileAttachmentAnnotation in it. However in order to get/download a file from FileAttachmentAnnotation please check following code snippet.
Document doc = new Document(dataDir + “input.pdf”)
foreach (Annotation annotation in doc.Pages[1].Annotations)
{
if (annotation.AnnotationType == AnnotationType.FileAttachment)
{
FileAttachmentAnnotation annot = (FileAttachmentAnnotation)annotation;
byte[] fileContent = new byte[annot.File.Contents.Length];
annot.File.Contents.Read(fileContent, 0,
fileContent.Length);
FileStream fileStream = new FileStream(dataDir + annot.File.Name + "_out" + ".txt",
FileMode.Create);
fileStream.Write(fileContent, 0, fileContent.Length);
fileStream.Close();
}
}
Please check in the above code that I have extracted content of the file from attachment and then save it to the disk using FileStream object. Please try using above approach to get the attachment from your document. In case if you still face any issue please share your input document so that we can test the scenario in our environment and share information accordingly.
Best Regards,
Thanks again Asad, this worked!
Hi Rudy,