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

Free Support Forum - aspose.com

Eliminate Bad Hyperlink from the PDF

Hi ,

I want to eliminate a bad hyperlink from the PDF uploaded . Is it possible to do using aspose?
Please guide me the steps if possible.

Observation :While uploading the pdf with a bad hyperlink the error message is generated

Thanks,
Shilpi

Any updates?

Please let me know…

Hi Shilpi,


Thanks for contacting support.

Can you please share some details on what is meant by bad hyperlinks i.e. broken links, incomplete links, destinations unreachable etc, and also please share some sample PDF file, so that we can further look into this matter and reply accordingly.

Hi ,

I am sending the sample pdf attached in the first post . The try2.pdf is a good hyperlink where one can navigate to the google.com

In the hyperlink.pdf the hyperlink embedded in it is a bad hyperlink as it does not naviagtes to any file.



My requirement is to replace the bad hyperlink with the plain text in the pdf.
Thanks,
Shilpi

Hi ,

Any update? Please let me know …I need it urgently

Thanks,
Shilpi

Hi Shilpi,


Thanks for sharing the resource file.

The following code snippet is used to get destination URL of each hyperlink inside PDF document but I am afraid the code is failing to retrieve information for your shared documents. For the sake of correction, I have logged this problem as PDFNEWNET-40123 in our issue tracking system. We will further look into the details of this problem.

Once this issue is resolved, as per your requirement, when destination for any link is being returned as blank/null, you can update the link color information and set openaction to null. For more information, please visit Update Links in a PDF File.

[C#]

//
Load source PDF file containing hyperlinks
<o:p></o:p>

Document document = new Document("c:/pdftest/16222-acrobat-device-gray.pdf");

// Traverse through all the page of PDF

foreach (Aspose.Pdf.Page page in document.Pages)

{

// Get the link annotations from particular page

Aspose.Pdf.InteractiveFeatures.Annotations.AnnotationSelector selector = new Aspose.Pdf.InteractiveFeatures.Annotations.AnnotationSelector(new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial));

page.Accept(selector);

// Create list holding all the links

System.Collections.IList list = selector.Selected;

// Iterate through invidiaul item inside list

foreach (Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation a in list)

{

// Print the destination URL

Console.WriteLine("Destination: " + (a.Action as Aspose.Pdf.InteractiveFeatures.GoToURIAction).URI + "");

}

}

Hi ,

I have the following code snippet which I am using to change the destination url :

foreach (Aspose.Pdf.Page page in pdfDocument.Pages)
{
Aspose.Pdf.InteractiveFeatures.Annotations.AnnotationSelector selector = new Aspose.Pdf.InteractiveFeatures.Annotations.AnnotationSelector(new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial));
page.Accept(selector);
System.Collections.IList list = selector.Selected;
foreach (Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation a in list)
{
if (a.Destination == null)
{
a.Action = new GoToURIAction("…");
}
}
}



I want to set the value of GoToURIAction as the value of the hyperlink text.
Please suggest me the method which shall return me the hyperlink text.

Also confirm me if the Destination check is correct to detect the bad hyperlink or not?


Also suggest me a way if i can change the hyperlink to plain text in the pdf and save it.

Thanks,
Shilpi

Hi Team ,

Any updates ? Looking for a reply :frowning:

Thanks,
Shilpi

Hi Shilpi,


Thanks for sharing the details and sorry for the delayed response.

As shared earlier, the API is having issues while retrieving LinkAnnotation information, so I am afraid the above stated code does not work. As soon as the problem is resolved, you will be able to retrieve hyperlink information. We are sorry for this inconvenience.