0

I want to know if it is possible to create pdf viewer element in R Shiny and change it reactively.

Example:

I have a list of pdf files in folder. Now pdf element should view the selected file and change dynamically with the input.

I have tried this using iframe but it does not change dynamically .Also pdf file should be present in www directory of shiny app....

tags$iframe(src='highl.pdf', height=550)

Can anyone help me to achieve this incase possible ?

Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
Paras Ghai
  • 363
  • 1
  • 6
  • 14
  • 1
    Possible duplicate of [displaying a pdf from a local drive in shiny](https://stackoverflow.com/questions/19469978/displaying-a-pdf-from-a-local-drive-in-shiny) – TimTeaFan Jul 26 '19 at 12:04

1 Answers1

1

I think you probably put the html tags in the ui section, something like this:

ui <- fluidPage(        
        sidebarLayout(
          sidebarPanel( selectinput(inputId = "pdf_selection", .. other stuff ..) ),
          mainPanel( tags$iframe(src = input$pdf_selection, height = 550) )                  
        )
      )
server <- function(input, output) { .. other stuff .. }

To render the PDF viewer dynamically by the reactive input, you should render it within the server section like:

ui <- fluidPage(        
        sidebarLayout(
          sidebarPanel( selectinput(inputId = "pdf_selection", .. other stuff ..) ),
          mainPanel( uiOutput("pdf_viewer") )                  
        )
      )
server <- function(input, output) {
  output$pdf_viewer <- renderUI( tags$iframe(src = input$pdf_selection, height = 550) )  
}
Mag1karp
  • 11
  • 1