TextFragmentAbsorber returns fragment with wrong rectangle

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)

@fedorino.alex

Thanks for contacting support.

We were able to reproduce the issue in our environment while using Aspose.PDF for .NET 20.4 and have logged it as PDFNET-47950 in our issue tracking system. We will further look into its details and keep you informed with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thank you @asad.ali.

Waiting for comments.

Can I see details of PDFNET-47950 ticket somewhere?

@fedorino.alex

The ticket has been attached to this thread where you can see its status. Along with that we will also keep you informed with the progress on investigation against it.

1 Like