Finding position of PDFSelectionMBS in a PDFSelectionMBS array

To find all occurrences of a search word in a PDF, I use

pdfSelectionArray = PDFView1.Document.FindString()

and when the user does a Find Again I use

pSelection = PDFView1.Document.FindStringFromSelection()

I’d like to locate the position of the second result in the initial array so the app can report the selected text is 1 of 10, 2 of 10, etc.

However, one can’t simply compare the PDFSelectionMBS objects. If I could get the PDFPage and starting location of the PDFSelectionMBS I could compare those, but I don’t see how that’s possible.

Is there a way to determine the position of a newly generated PDFSelectionMBS in an existing PDFSelectionMBS array?

this may be complicated and not built-in.
You may her to see for each page whether it is in the list of pages for the other document.
and then also compare the ranges for two pages.

I need to compare selections, and there is no range in PDFSelectionMBS. There is an attributedString property, which has a location, that’s always 0 (which I assume means that it’s not related to the document or page location, but to itself, and thus always begins at 0).

To be clear, I have an array of selections (returned by the findString method) and then the current selection. How to tell where the current selection is in the array?

Look on PDFSelectionMBS:

loop over pages to ask then for number of ranges and get all ranges per page.

Thank you! It’s kind of cumbersome, but I think it can work. I’ll give it a shot.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.