- Code: Select all
private void AddHyperlinks(PdfDocument pdfDocument)
{
var page = pdfDocument.GetSpecificPageByIndex(1);
PdfTextFinder finder = new PdfTextFinder(page);
finder.Options.Parameter = TextFindParameter.IgnoreCase;
var pdfTextFragments = finder.FindAllText();
foreach (var textFragment in pdfTextFragments)
{
foreach (var bounds in textFragment.Bounds)
{
PdfUriAnnotation url = new PdfUriAnnotation(bounds);
url.Uri = "https://en.wikipedia.org/wiki/Climate_change";
url.Border = new PdfAnnotationBorder(1f);
url.Color = Color.Blue;
clarificationPage.Annotations.Add(url);
}
}
}
Whenever I inspect the textFragment I get the following information
As you can see the Text parameter is filled with "\0\0\0" instead of text.
This also prevents me from using the finder.Find("text") because it won't match with the value in pdfTextFragment.text.
Hopefully you can help me.