Updating the text displayed for a hyperlink

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Updating the text displayed for a hyperlink

I'm trying to update hyperlinks in pdf files using c# and iTextSharp.

I've reached the point where I can get the hyperlinks, reset them to what I need, but cannot find out how to change the text related to the link.

This code gets the text that is displayed,

var LinkLocation = AnnotationDictionary.GetAsArray(PdfName.RECT);
                            iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(((PdfNumber)LinkLocation[0]).FloatValue, ((PdfNumber)LinkLocation[1]).FloatValue, ((PdfNumber)LinkLocation[2]).FloatValue, ((PdfNumber)LinkLocation[3]).FloatValue);
                            RenderFilter[] renderFilter = new RenderFilter[1];
                            renderFilter[0] = new RegionTextRenderFilter(rect);
                            ITextExtractionStrategy textExtractionStrategy = new FilteredTextRenderListener(new LocationTextExtractionStrategy(), renderFilter);
                            string linkTextBuilder = PdfTextExtractor.GetTextFromPage(R, i, textExtractionStrategy).Trim();

but as it only returns a string I have no object to access to set the text. I've searched extensively and it seems I could try and find the rectangle the link text is in and change that, but my new text may be a different length and may affect the pdf layout.

Any help gratefully received.