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

Free Support Forum - aspose.com

Change hyperlink to plain text in pdf

Hi Team ,
Suggest me a way to change the hyperlink to plain text in the pdf and save it .

Thanks,
Shilpi

Hi Team ,


I have the following code snippet by which I am able to pick the hyperlink name


//// 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;
//// if (list.Count > 0)
//// {
//// annotation = (Annotation)list[0];
//// using (var pdfReader = new PdfReader(HttpContext.Current.Server.MapPath(savePath)))
//// {
//// if (annotation != null)
//// {
//// float distanceInPixelsFromLeft = (float)annotation.Rect.LLX;
//// float distanceInPixelsFromBottom = (float)annotation.Rect.LLY;
//// float width = (float)annotation.Rect.Width;
//// float height = (float)annotation.Rect.Height;

//// var rect = new System.util.RectangleJ(
//// distanceInPixelsFromLeft,
//// distanceInPixelsFromBottom,
//// width,
//// height);

//// var filters = new RenderFilter[1];
//// filters[0] = new RegionTextRenderFilter(rect);

//// ITextExtractionStrategy strategy =
//// new FilteredTextRenderListener(
//// new LocationTextExtractionStrategy(),
//// filters);
//// for (int i = 1; i < pageCount + 1; i++)
//// {
//// var link = PdfTextExtractor.GetTextFromPage(
//// pdfReader,
//// i,
//// strategy);

//// link =
//// Encoding.UTF8.GetString(Encoding.Convert(
//// Encoding.Default,
//// Encoding.UTF8,
//// Encoding.Default.GetBytes(link)));
//// hyperlink = link.ToString();
//// words= hyperlink.Split(’ ');
//// String firstThree = String.Empty;
//// foreach (String word in words)
//// {
//// firstThree = word != null ?
//// word.Substring(0, word.Length >= 3 ? 3 : word.Length) : null;
//// if (firstThree == “www”)
//// {
//// nevigate = word;
//// }
//// }

//// }


//// }
//// }
//// }



I just want to replace hyperlink with the text returned from the rectangle co-ordinates
Any updates ? Looking for a reply :frowning:

Thanks,
Shilpi

Hi Shilpi,


Thanks for contacting support.

I am afraid the API currently does not support the feature to change/remove URL of hyperlink text. However for the sake of correction, we already have logged this requirement as PDFNEWNET-33327 in our issue tracking system. We will further look into the details of this requirement and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.