Thanks for your inquiry. Please check the last section of update hyperlinks in PDF documentation.
It describes how to change hyperlink text color and how you may also use the same code to set the Text property of TextFragment to change the text. Please check the following sample code snippet. Hopefully, it will help you accomplish the task.
Document doc = new Document("input.pdf");
// get the first link annotation from the first page of the document
LinkAnnotation linkAnnot = (LinkAnnotation)doc.Pages[1].Annotations[1];
if (linkAnnot.Action is GoToURIAction)
{
// Modification link: change link URI
GoToURIAction goToAction = (GoToURIAction)linkAnnot.Action;
// specify the URI for the link object
goToAction.URI = "www.google.com";
// save the document with the updated link
// search the text under the annotation
TextFragmentAbsorber ta = new TextFragmentAbsorber();
Aspose.Pdf.Rectangle rect = linkAnnot.Rect;
rect.LLX -= 10;
rect.LLY -= 10;
rect.URX += 10;
rect.URY += 10;
ta.TextSearchOptions = new TextSearchOptions(rect);
ta.Visit(doc.Pages[1]);
// Change color and text.
foreach (TextFragment tf in ta.TextFragments)
{
tf.TextState.ForegroundColor = Aspose.Pdf.Color.Red;
tf.Text = "ClickHere";
}
}
doc.Save("output.pdf");
Please feel free to contact us for any further assistance.
- adjust that URL is for complete long TextToDisplay
Simply I set
objAnnotation.Rect = tf.Rectangle;
where tf.Rectangle is new size of extended text.
Still open problem is overlapping :( but I saw that there are also other users having same issue so I hope that you will resolve it quickly as this really impacts changes of texts in PDF by corrupting display/text.
Thanks for sharing the details and sorry for the delayed response.
We are glad to hear that you have managed to resolve Adjust URL for complete long TextToDisplay. However we are working on testing text overlap issue and will keep you posted with our findings.
PS, there have been some scenarios where some other customers have also reported text overlap issue but for individual customer documents, we explicitly test the scenario as it depends upon the structure of input file.
Thanks for your patience. We have tested the scenario and noticed the text overlapping issue with long text and logged a ticket PDFNEWNET-40024 in our issue tracking system for further investigation and rectification. We will update you as soon as it is resolved.
I am afraid the earlier reported issues is still pending for review as the team has been busy fixing other previously reported priority issues. However the product team will surely consider investigating/fixing it as per development schedule and as soon as we have some definite updates regarding its resolution, we will let you know. Please be patient and spare us little time. We are sorry for this delay and inconvenience.
Thanks for your patience and sorry for the delayed response.
I am afraid the earlier reported issue is not yet resolved as the team has been recently busy fixing some other previously reported high priority issues. However I have intimated the product team to share the possible time-frame regarding its resolution. As soon as we have some further updates, we will let you know.