We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TextFragmentAbsorber retruns fragment with wrong rectangle when text rotated

I have a PDF file where text is inside rotated table.
I try to find some text TextFragmentAbsorber returns fragments and its rectangle has offset on X coordinate. And when I set BackgroundColor for returned fragment - I have highlighting in a wrong place.

Could you please help with it?

Code:

class Program
{
    static void Main(string[] args)
    {
        System.Console.WriteLine("TextFragmentAbsorber in rotated text");

        var license = new License();
        using (var licenseStream = System.IO.File.OpenRead("Aspose.Pdf.lic"))
        {
            license.SetLicense(licenseStream);
        }

        using (var pdfDocument = new Document("rotated_page.pdf"))
        {
            var fragmentsAbsorber = new TextFragmentAbsorber("ASTM");
            fragmentsAbsorber.Visit(pdfDocument);

            if (fragmentsAbsorber.TextFragments.Count == 0)
            {
                System.Console.WriteLine("Nothing was found...");
                return;
            }

            System.Console.WriteLine($"Found: {fragmentsAbsorber.TextFragments.Count}");

            foreach (var fragment in fragmentsAbsorber.TextFragments)
            {
                fragment.TextState.DrawTextRectangleBorder = true;
                fragment.TextState.BackgroundColor = Color.Coral;
            }

            pdfDocument.Save("out.test.pdf");
        }
    }
}

File with rotated text is here: rotated_page.pdf (33.9 KB)

@Victor_Boschuk,

We are looking into this and will get back to you with feedback soon.