OCR removes bookmarks / table of contents entries

For anyone coming across this thread while searching for a solution (as I did), I have written a script that helps work around this quirk of the OCR component: