Support,
I have a PDF file and text inside, when I try to find this text TextFragmentAbsorber returns fragment and its rectangle has offset on Y coordinate. And wnen I set BackgroundColor for returned fragment - I have highlighting in a wrong place.
Can you help us?
This code we have:
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("Hello Aspose!");
License license = new License();
using (var licenseStream = System.IO.File.OpenRead("Aspose.Pdf.lic"))
{
license.SetLicense(licenseStream);
}
using (Document pdfDocument = new Document("test.pdf"))
{
var fragmentsAbsorber = new TextFragmentAbsorber("ISO/IEC Directives, Part 1");
fragmentsAbsorber.Visit(pdfDocument);
System.Console.WriteLine($"Found: {fragmentsAbsorber.TextFragments.Count}");
if (fragmentsAbsorber.TextFragments.Count == 0)
{
System.Console.WriteLine("Nothing was found...");
return;
}
var fragment = fragmentsAbsorber.TextFragments[1];
fragment.TextState.DrawTextRectangleBorder = true;
fragment.TextState.BackgroundColor = Color.Coral;
pdfDocument.Save("out.test.pdf");
}
}
}
the file with text is here: test.pdf (154.9 KB)