I am not able to extract Linkannotation action for specific document. Annotation Action shows null.
The following code i have used for extracting Linkannotations.
foreach (Page pageDic in psd)
{
int page = pageDic.Number;
string sourcePage = page.ToString();
annots = pageDic.Annotations;
for (int index = 1; index <= annots.Count; index++)
{
Annotation annot = annots[index];
string Aname = annot.GetType().Name;
if (Aname.Equals("LinkAnnotation"))
{
}
}
}
in the above code, while iterating each link, annot abject shows Action as null.
i am able to replicate this issue in the attached document, Please give me the solution to solve this issue ASP. Test.pdf (83.4 KB)
We tested the scenario with your file and noticed that Action property was null. However, it seems like the links in PDF file are not working and pointing to any valid destination. As PDF has single page, the Action of LinkAnnotation may have removed. Would you please share how you generated or from which source you obtained this document. Also, would you please try with a PDF that has links with valid destinations.
In the attached document links are valid, because i can able to extract link properties with action in acrobat and some other third party library except Aspose. In Aspose only i am not able to extract.
Is there any other way to extract LinkAnnotation properties with Action in Aspose?
Please response ASP, we are facing this as major issue in my project.
we are facing same issue for bookmarks also.Please find the attached document about the document.
The Document contained 5 bookmarks and each bookmark had action as GoToAction and destination page number as 1. when i am extracting bookmark action using Aspose, action getting as null.
bellow code i am using for bookmark action.
For your first issue (Action of LinkAnnotation is returned as null), we have logged a ticket as PDFNET-46719 in our issue tracking system. We will further look into details of the issue and keep you posted with the status of its correction. Please spare us little time.
We have tested the scenario and managed to observe similar issue. However, in case you need to determine destination page number of the bookmark - you can get it from childOutline.Destination property as following:
foreach (OutlineItemCollection Bookmark in pdfDocument.Outlines)
{
OutlineItemCollection childOutline = Bookmark;
var dest = ((Aspose.Pdf.Annotations.ExplicitDestination)childOutline.Destination);
var pagenumber = dest.PageNumber;
}
If above workaround does not fulfill your requirements, please let us know. We will further proceed to help you accordingly.
Hi
my requirement is to extract action for links and bookmarks. but in the above 2 documents i am getting action as null. please give me the solution to extract action for links and bookmarks.
We have logged another issue as PDFNET-46726 in our issue tracking system for bookmark related behavior of the API. We will look into details of it and keep you informed with its resolution status. Please spare us little time.
In case you have further inquiries about Aspose.Words, please feel free to post your query in Aspose.Words forum. We will be assisting you accordingly.
We have investigated the tickets (PDFNET-46719, PDFNET-46726). According to PDF specification, Link Annotations may be associated with Actions or Destinations.
A (Optional; PDF 1.1) An action that shall be performed when the link annotation is activated (see 12.6, “Actions”).
Dest (Optional; not permitted if an A entry is present) A destination that shall be displayed when the annotation is activated (see 12.3.2, “Destinations”).
In your documents, XYZ (X,Y, Zoom) destinations are associated with link annotations.
Please try the following code snippet:
[PDFNET-46719] - Action Property of LinkAnnotation is NULL
Document pdfDocument = new Document(dataDir + "Test (1).pdf");
foreach (Page p in pages)
{
foreach (Annotation anno in p.Annotations)
{
if (anno.AnnotationType == AnnotationType.Link)
{
LinkAnnotation linkAnno = (LinkAnnotation)anno;
var action = linkAnno.Action; // This is always null
IAppointment dest = linkAnno.Destination; //XYZ explicit destination
Console.WriteLine(dest);
}
}
}
[PDFNET-46726] - Action Property of Bookmarks is NULL
Document pdfDocument = new Document(dataDir + "Test (1).pdf");
foreach (OutlineItemCollection Bookmark in pdfDocument.Outlines)
{
OutlineItemCollection childOutline = Bookmark;
Aspose.Pdf.Annotations.PdfAction action = childOutline.Action;
IAppointment dest = childOutline.Destination;
Console.WriteLine(dest);
}