'Render a PDF within Shiny and highlight text in the PDF document

I am trying to render a PDF file in Shiny and highlight a particular sentence that I know appears in the PDF, on a specific page. For example, I know that the text "voyage of the Beagle" is found on page 10 of the PDF file called "Darwin.pdf". The ui.R file of my app contains this element, where the PDF document will be rendered:

fluidRow(uiOutput("pdfview"))

In the server.R file, this is the code that I have which is now displaying the correct page 10 of the PDF:

output$pdfview <- renderUI({
            tags$iframe(style="height:600px; width:100%", src="Darwin.pdf#page=10")
        })

My question is, how can I get the text "voyage of the Beagle" to be highlighted when the PDF file is rendered? I know that HTML5 contains the

<mark></mark>

tag which would do this work, but it seems I need to extract the raw HTML from the rendered iframe first, and then insert these tags somehow? I am not sure how to access that rendered HTML, nor send it onward to the UI if I do some editing of it. Maybe there is another approach. Any help much appreciated!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source