We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to make existing annot action as null in Aspose

Hi,

I would like to make existing annots action as none in aspose. When I split the document into multiple files, existing annots shows with goto action without target page, if the target page does not exists. I want to make those annots as null. I have attached the document and in page number 6.test.pdf (48.2 KB)

I am using below code snippet to extract those annots and make action as none.
IList list = selector.Selected;
foreach (LinkAnnotation linkannot in list)
{
string Aname = linkannot.GetType().Name;

                if (Aname.Equals("LinkAnnotation"))
                {
                 actiontype = action.GetType().Name;

                if (actiontype.Equals("GoToAction"))
                   {
                        GoToAction gotoaction = null;
                        gotoaction = (GoToAction)annot.Action;
                        ExplicitDestination destination = (ExplicitDestination)gotoaction.Destination;
                        int ipage = destination.PageNumber;
                        if (ipage == 0)
                     annot.Action = null;

}

But this code is not working to make action null. Please let me know how can I make action none for these types of annots.

Thanks in advance,

Sow

@M_Sowbhagya

We have checked the document that you have shared and found that the Annotation Action was already NULL at page 6. Furthermore, if you want to remove the action, you can delete link annotation using following code snippet:

Document doc = new Document(dataDir + "test (1).pdf");
Page page = doc.Pages[6];
foreach(Annotation annot in page.Annotations)
{
 if(annot is LinkAnnotation)
 {
  var action = ((LinkAnnotation)annot).Destination;
  page.Annotations.Delete(annot);
 }
}
doc.Save(dataDir + "output.pdf");

OUTPUT.pdf (46.7 KB)

Thanks for the reply. I do not want to delete annotations. The annot shows with GotoAction without target page in the page 6. I want to make action as ‘None’ with an annot. Please let me know how to solve this issue.

Thanks,
Sow

@M_Sowbhagya

As shared earlier, the action of the annotation at page 6 were already NULL. Would you please share complete sample code snippet so that we can again test the scenario in our environment and address it accordingly.

Thanks for the reply. The page 6 contain action as ‘Goto’ in the properties. If we open the document in Acrobat, it shows as Action as Goto page. I want to make action as none. I tried different methods like by deleting action.
linkannot.Actions.Delete(i);
and
linkannot.Destination = null.
But its not working. Please help me how to solve this issue.

Thanks,

sow

@M_Sowbhagya

Thanks for sharing further details.

We were able to notice that action of the link annotation was not being set as NULL using Aspose.PDF for .NET 20.5. However, we further need to investigate the feasibility of this requirement and for the purpose, we have logged an investigation ticket as PDFNET-48338 in our issue tracking system. We will investigate the feasibility of your requirements and keep you posted with the status of ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.