Solution 1 :

For PDF, I don’t know. For images, you can try the JavaScript library imgViewer2.

library(shiny)

js <- '$(document).ready(function(){ $("#myimage").imgViewer2(); });'

ui <- fluidPage(
  tags$head(
    tags$link(
      rel = "stylesheet", 
      href = "https://unpkg.com/[email protected]/dist/leaflet.css"),
    tags$link(
      rel = "stylesheet", 
      href = "http://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css", 
      media = "screen"),
    tags$script(src = "https://unpkg.com/[email protected]/dist/leaflet.js"),
    tags$script(src = "http://code.jquery.com/ui/1.12.1/jquery-ui.min.js"),
    tags$script(
      src = "https://cdn.jsdelivr.net/npm/[email protected]/src/imgViewer2.min.js"),
    tags$script(HTML(js))
  ),
  br(),
  tags$img(id = "myimage", 
           src = "https://images.plot.ly/language-icons/api-home/r-logo.png", 
           width = "20%")
)

server <- function(input, output, session){}

shinyApp(ui, server)

Or the panzoom library:

library(shiny)

js <- '
$(document).ready(function(){ 
  var img = document.getElementById("myimage");
  panzoom(img);
});'

ui <- fluidPage(
  tags$head(
    tags$script(
      src = "https://unpkg.com/[email protected]/dist/panzoom.min.js"),
    tags$script(HTML(js))
  ),
  br(),
  tags$img(id = "myimage", 
           src = "https://images.plot.ly/language-icons/api-home/r-logo.png", 
           width = "20%")
)

server <- function(input, output, session){}

shinyApp(ui, server)

Or give a try to the R package svgPanZoom.

Problem :

Is there any good tool/UI widgets to visualize a large image/pdf document. Hopefully a tool that behaves like how google map is being visualize, where you have the zoom functionality and can drag to different parts of the image

By