I have a PDF file that is constantly being updated and overwritten. It is saved in the www
directory of the Shiny working directory. The problem is that the changes aren't being displayed in the app. The app still displays the first version of the pdf.
I originally had everything in the UI. I used tags$iframe
in the ui.r code with the src pointing directly to the pdf file in the www
directory.
Then I noticed that the pdf wasn't updating, so I tried to make an action button that when pushed would run the tags$iframe
and display the pdf. This did not solve the problem. The updates in the pdf file are still not being displayed.
First attempt with everything in the UI
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
h3("Title")
),
mainPanel(
tabsetPanel(
tabPanel("Tab 1",
tags$iframe(style="height:1200px; width:100%; scrolling=yes",
src="PDF1.pdf"))
)
)
)
)
server <- function(input, output,session){
}
shinyApp(ui, server)
Second attempt with the action button
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
h3("Title")
),
mainPanel(
tabsetPanel(
tabPanel("Tab1",
sidebarLayout(
sidebarPanel(
actionButton("refresh_1", "Refresh PDF")
),
mainPanel(
uiOutput("Show_PDF1")
)
)
)
)
))
)
server <- function(input, output,session){
observeEvent(input$refresh_1, {
output$Show_PDF1 <- renderUI({
tags$iframe(style="height:1200px; width:100%; scrolling=yes", src="PDF1.pdf")
})
})
}
shinyApp(ui, server)
I am hosting the app on a non pro version of shiny server, and accessing it with chrome. To recreate the problem you can put any pdf file into the /srv/shiny-server/www
directory with the name PDF1.pdf, and access the app. Then overwrite PDF1.pdf with another pdf file and run the app again. You will see that the app is still displaying the original PDF1.pdf file.