简体   繁体   English

在R上显示PDF文件吗?

[英]Display PDF file in R shiny?

I want to know if it is possible to create pdf viewer element in R Shiny and change it reactively. 我想知道是否可以在R Shiny中创建pdf查看器元素并进行反应性更改。

Example: 例:

I have a list of pdf files in folder. 我在文件夹中有一个pdf文件列表。 Now pdf element should view the selected file and change dynamically with the input. 现在pdf元素应该查看选定的文件,并随输入动态变化。

I have tried this using iframe but it does not change dynamically .Also pdf file should be present in www directory of shiny app.... 我已经尝试过使用iframe进行尝试,但它不会动态更改。此外,闪亮应用程序的www目录中还应存在pdf文件。

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

Can anyone help me to achieve this incase possible ? 有人可以帮助我实现这一目标吗?

I think you probably put the html tags in the ui section, something like this: 我认为您可能将html标签放在ui部分中,如下所示:

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: 要通过反应性输入动态呈现PDF查看器,您应该在服务器部分中进行呈现,如下所示:

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) )  
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM