Shinyapps pdf不在iframe的屏幕上显示

时间:2017-03-06 21:52:10

标签: html r pdf iframe shiny

我想在屏幕上显示pdf。 pdf的源由两个用户输入指定,输入$ folder和input $ report。我试图将它们连接在一起以构成iframe的源代码,但我一直遇到问题。以下是我的代码:

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=(paste0("Reports/", input$folder, "/", input$report)), height=300, width=600)
  })



}

shinyApp(ui = ui, server = server)

当我运行应用程序时,它会在iframe中显示错误NOT FOUND,如下所示:

error picture

我已经通过运行此代码

进行了测试,以查看该文件是否已被实际识别
file.exists(paste0("Reports/", input$folder, "/", input$report))

并返回true表示可以通过粘贴输入找到我的文件。我也没有在查看器中运行代码,我在窗口和浏览器中运行它以进行测试,因此我知道它不是一个不显示pdfs问题的查看器。为什么我可以验证文件是否存在但在尝试在iframe中显示时却找不到它?

0 个答案:

没有答案