I am modifying case in strings. Each time I either upper or lower case a character I want to highlight it. I am able to get some documents to work but others do not work at all. Instead the annotation is no where near the text. Here is the code:
private void AnnoatateUpdates(string before, TextFragment textFragment, int startIndex)
{
string letter = before.Substring(startIndex, 1);
for (int segNum = 1; segNum <= textFragment.Segments.Count; segNum++)
{
TextSegment segment = textFragment.Segments[segNum];
if (segment.EndCharIndex > startIndex)
{
var leftChar = segment.Characters[startIndex + 1];
Aspose.Pdf.Rectangle rect = leftChar.Rectangle;
Aspose.Pdf.Annotations.HighlightAnnotation highlightText = new Aspose.Pdf.Annotations.HighlightAnnotation(textFragment.Page, rect);
highlightText.Opacity = 0.5;
highlightText.Color = Aspose.Pdf.Color.Red;
textFragment.Page.Annotations.Add(highlightText);
}
}