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

Free Support Forum - aspose.com

Update links on pdf

Hi

while trying to update links on pdf (LinkAnnotation) , sometimes the action is null

and then trying to use the destination value instead (NamedDestination) I get the value of something like : {d0e74} which I dont know what it means

can anybody help me with this?

appreciate your help

LinkAnnotation linkAnno = (LinkAnnotation)i;

if (linkAnno.Action != null)

{

if (linkAnno.Action.GetType().Name == “GoToRemoteAction”)

{

}

else if (linkAnno.Action.GetType().Name == “GoToURIAction”)

{

uriAction = ((GoToURIAction)linkAnno.Action);

string n = uriAction.URI;

Console.WriteLine(">>>>" + n);

Logger.LogMessage(">>>>" + n);

Console.WriteLine(" ------- " + docName);

Logger.LogMessage(" ------- " + docName);

}

}

else if (linkAnno.Destination is ExplicitDestination)

{

ExplicitDestination explicitDest = (ExplicitDestination)linkAnno.Destination;

System.Console.WriteLine("{0}[{1}]", i, explicitDest.PageNumber);

}

else if (linkAnno.Destination is NamedDestination)

{

NamedDestination namedDest = (NamedDestination)linkAnno.Destination;

System.Console.WriteLine("{0}[{1}]", i, doc.Destinations.GetPageNumber(namedDest.Name, false));

}

Hi Iris,


Thanks for contacting support.

Can you please share your input document, so that we can test the scenario in our environment. We are sorry for this inconvenience.

attached the file - look links on page 30

starts with : myhpindigo

thx
Iris

Hi Iris,

Thanks for sharing the resource file.

I have tried accessing the hyperlink inside PDF file on page 30 and I am getting IndexOutOfRangeException. Can you please share some sample project, so that we can test the scenario in our environment. We are sorry for this inconvenience.

[C#]

using (Document pdfDocument
= new Document(“c:/pdftest/CA494-18500±+In-Mold+Labeling+(IML)+for+HP+Indigo+L%26P+How+to+Guide.pdf”))<o:p></o:p>


{

Console.WriteLine(pdfDocument.Pages[30].Annotations[1]);

LinkAnnotation linkAnno = (LinkAnnotation)pdfDocument.Pages[30].Annotations[5];


if (linkAnno.Action != null)

{

if (linkAnno.Action.GetType().Name == "GoToRemoteAction")

{

//Console.WriteLine("LinkAnnotation >>>> GoToRemoteAction");

}

else if (linkAnno.Action.GetType().Name == "GoToURIAction")

{

GoToURIAction uriAction = ((GoToURIAction)linkAnno.Action);

string n = uriAction.URI;

Console.WriteLine(">>>>" + n);

// Logger.LogMessage(">>>>" + n);

Console.WriteLine(" ------- " + pdfDocument.FileName);

// Logger.LogMessage(" ------- " + docName);

}

}

else if (linkAnno.Destination is ExplicitDestination)

{

ExplicitDestination explicitDest = (ExplicitDestination)linkAnno.Destination;

System.Console.WriteLine("{0}[{1}]", pdfDocument.Pages[30].Annotations[5], explicitDest.PageNumber);


}

else if (linkAnno.Destination is NamedDestination)

{

NamedDestination namedDest = (NamedDestination)linkAnno.Destination;

System.Console.WriteLine("{0}[{1}]", pdfDocument.Pages[30].Annotations[5], pdfDocument.Destinations.GetPageNumber(namedDest.Name, false));


}

pdfDocument.Save("c:/pdftest/LInkUpdated.pdf");

}

attach a simple console application project with main and only file


thx
Iris

Hi Iris,


Thanks for sharing the sample project.

I have tested the scenario and I am able to
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWNET-40500 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.