I have been working on a shiny app that will allow users to pick a pdf from a file directory that is in the app and display it on screen using an iframe by letting users first select the folder that holds the pdfs, and then select a specific pdf inside of that folder. However, the way I have it setup now will not display the pdf on the screen, it instead shows a not found error in the iframe.
Here is my code:
library(shiny)
ui <- fluidPage(
headerPanel("Client"),
selectInput("folder", "Select the report type",
c(dir("Reports/"))),
conditionalPanel(
condition = "input.folder == 'Invoice Analysis'",
selectInput("report", "Choose the PDF",
choices = dir("Reports/Invoice Analysis"))),
conditionalPanel(
condition = "input.folder == 'Pole Attachments'",
selectInput("report", "Choose the PDF",
choices = dir("Reports/Pole Attachments"))),
htmlOutput("pdfviewer")
)
server <- function(input, output){
output$pdfviewer <- renderUI({
tags$iframe(src=(input$report), height=300, width=600)
})
}
shinyApp(ui = ui, server = server)
Here is the current output:
I can replace the src in the iframe with a website and it displays the site correctly.
example:
tags$iframe(src=("http://www.w3schools.com"), height=300, width=600)
This leads me to believe that somehow I am getting this section of my code wrong. I have also tried something like this:
tags$iframe(src=(paste0(input$folder, input$report), height=300, width=600)
but it gives me the same not found error. Can anyone think of a way to make the source of the iframe a selection from the user? I am very new at r and shinyapps so I don't know if this is a syntax problem, or if I am going about this the wrong way. Thank you in advance for the help.