Text highlighting via script-function

Glad it’s useful. You wrote

and I’m wondering in what situation that would be necessary. Does it perhaps have something to do with PDFs that got corrupted by PDFKit (i.e. applying annotations of a corrupted PDF to a new PDF)?