Hi,
Hello John,
Thanks for using our products.
Please visit the following link for information on Get All Annotations from the Page of a PDF document. In case you still face any problem, can you please share the source PDF document so that we can test the scenario at our end. We apologize for your inconvenience.
FYI, you may also use Aspose.Pdf for .NET to extract following information
Hi,
Hi John,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for sharing the sample code and template file.
We have found your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-30245. You will be notified through this forum thread once the issue gets resolved.
Sorry for the inconvenience.
The issues you have found earlier (filed as 30245) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
Great!
Hi John,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Please accept our apologies regarding the re-occurrence of the issue. I have tested the scenarios you mentioned and indeed the issues are still occurring in the latest version of Aspose.Pdf. I have re-opened the issue and informed the development team to further look into it. We will update you as soon as any feedback is shared by the development team.
We are really sorry for the inconvenience caused,
Hi John,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
I got the following reply from our development team regarding your issue. I would like to share it with you so you can change your code accordingly to avoid the exceptions you are currently getting while reading the annotations.
As per the details from development team, when we try to iterate the collection we must use the highest possible general type for variable (C# rule). PdfDoc.Pages[i].Annotations is collection of annotations, where Annotation is the base class for all annotations (MarkupAnnotaion, LinkAnnotaion) but LinkAnnotaion is different from MarkupAnnotation. So, these annotations have different sets of properties (like LinkAnnotation (and some other) does not contain properties as Title and Subject), so for each value in annotation collection we must identify the exact type and then call the properties of that type.
Following is the sample code for your reference:
Document PdfDoc = new Document("PDFTest1.pdf", "Password");
string comments = "";
for (int i = 1; i <= PdfDoc.Pages.Count; i++)
{
try
{
foreach (Annotation annotation in PdfDoc.Pages[i].Annotations)
{
string s = string.Format("{0} Page: {1} ; Title: {2} ; Subject : {3} ; Contents :{4} \n",
comments,
i,
annotation is MarkupAnnotation ? ((MarkupAnnotation)annotation).Title : string.Empty,
annotation is MarkupAnnotation ? ((MarkupAnnotation)annotation).Subject : string.Empty,
annotation.Contents);
Console.WriteLine(s);
}
}
catch (Exception ex)
{
//Handle exception
}
}
Console.ReadLine();
In case you have any further query, please feel free to contact us.
Thank You & Best Regards,