TextSearch produces highlights with no quads

Product: pdftron.PDF SDK for .Net

Product Version: 9.2.7

Please give a brief summary of your issue:
Getting weird highlights from TextSearch results

Please describe your issue and provide steps to reproduce it:
I am evaluating pdftron for creation of tool that will need to search PDF text, then will create annotations from search hit bounding boxes. When I run search and process results I see that highlights for some search resuls return empty quads array from GetCurrentQuads(). To reproduce this I modified your sample PDFViewWPFTest: I added test code to function that changes selection on page when user changes selected search result. This is function in file…\PDFNetDotNet4\PDFNetDotNet4\Samples\PDFViewWPFTest\CS\Controls\WholeDocumentSearchControl.xaml.cs. Code is below and there are no other changes to the sample.
When I run the program under debugger I see output like this:

Hit index 0; page 1; quad length 8; quads 1
Highlight: rect (543.79302893:744.91094036 - 552.75036263:753.92207186)
Hit index 0; page 1; quads 1
Selection: rect (97.85231686:314.031258427695 - 134.69663682:324.22595904)
Hit index 1; page 1; quad length 0; quads 0
Hit index 1; page 1; quads 1
Selection: rect (253.86378593:206.427640087695 - 291.93469573:216.6223407)
Hit index 2; page 1; quad length 0; quads 0
Hit index 2; page 1; quads 1
Selection: rect (514.65243736:182.503499257695 - 552.72334716:192.69819987)

My test code checks quads length, then this highlight is selected and I am obtaining quads from selection. In all cases text is correctly selected, but I am getting no quads. Here is modified function:

private void ListSearchResults_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
/*
if (ListSearchResults.SelectedIndex >= 0)
{
Highlights hlt = hlt_list[ListSearchResults.SelectedIndex];

            hlt.Begin(_doc);

            _current_viewer.SetCurrentPage(hlt.GetCurrentPageNumber());
            _current_viewer.Select(hlt);
            _current_viewer.SetVScrollPos(_current_viewer.GetVScrollPos());
            _current_viewer.SetHScrollPos(_current_viewer.GetHScrollPos());

            _toolManager.CurrentTool.TextSelectionHasChanged();
        }
        */
        if (ListSearchResults.SelectedIndex >= 0)
        {
            Highlights hlt = hlt_list[ListSearchResults.SelectedIndex];

            hlt.Begin(_doc);
            int pageNumber = hlt.GetCurrentPageNumber();
            // Test
            double[] quads = hlt.GetCurrentQuads();
            int quad_count = quads.Length / 8;
            Debug.WriteLine($"Hit index {ListSearchResults.SelectedIndex}; page {pageNumber}; quad length {quads.Length}; quads {quad_count}");
            for (int i = 0; i < quad_count; i++)
            {
                int offset = 8 * i;
                double x1 = Math.Min(Math.Min(Math.Min(quads[offset + 0], quads[offset + 2]), quads[offset + 4]), quads[offset + 6]);
                double x2 = Math.Max(Math.Max(Math.Max(quads[offset + 0], quads[offset + 2]), quads[offset + 4]), quads[offset + 6]);
                double y1 = Math.Min(Math.Min(Math.Min(quads[offset + 1], quads[offset + 3]), quads[offset + 5]), quads[offset + 7]);
                double y2 = Math.Max(Math.Max(Math.Max(quads[offset + 1], quads[offset + 3]), quads[offset + 5]), quads[offset + 7]);
                Debug.WriteLine($"Highlight: rect ({x1}:{y1} - {x2}:{y2})");
            }
            // Test
            _current_viewer.SetCurrentPage(hlt.GetCurrentPageNumber());
            _current_viewer.Select(hlt);
            // Test
            pdftron.PDF.PDFViewWPF.Selection s = _current_viewer.GetSelection(pageNumber);
            quads = s.GetQuads();
            quad_count = quads.Length / 8;
            Debug.WriteLine($"Hit index {ListSearchResults.SelectedIndex}; page {pageNumber}; quads {quad_count}");
            for (int i = 0; i < quad_count; i++)
            {
                int offset = 8 * i;
                double x1 = Math.Min(Math.Min(Math.Min(quads[offset + 0], quads[offset + 2]), quads[offset + 4]), quads[offset + 6]);
                double x2 = Math.Max(Math.Max(Math.Max(quads[offset + 0], quads[offset + 2]), quads[offset + 4]), quads[offset + 6]);
                double y1 = Math.Min(Math.Min(Math.Min(quads[offset + 1], quads[offset + 3]), quads[offset + 5]), quads[offset + 7]);
                double y2 = Math.Max(Math.Max(Math.Max(quads[offset + 1], quads[offset + 3]), quads[offset + 5]), quads[offset + 7]);
                Debug.WriteLine($"Selection: rect ({x1}:{y1} - {x2}:{y2})");
            }
            // Test
            _current_viewer.SetVScrollPos(_current_viewer.GetVScrollPos());
            _current_viewer.SetHScrollPos(_current_viewer.GetHScrollPos());

            _toolManager.CurrentTool.TextSelectionHasChanged();
        }

Please advise how it possible to get correct highlights coordinates.

Thanks,
Sergei

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Is this issue file specific?

If yes, please provide the PDF file you are using.

Hi Ryan, no it happens with all files I tried.

–Sergei