Created
November 21, 2017 08:04
-
-
Save amrrs/184006b54a0cbe6baa62595cf7c4fdb4 to your computer and use it in GitHub Desktop.
How to upload and embed pdf in R shiny (iframe)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
ui <- shinyUI(fluidPage( | |
titlePanel("Testing File upload"), | |
sidebarLayout( | |
sidebarPanel( | |
fileInput('file_input', 'upload file ( . pdf format only)', accept = c('.pdf')) | |
), | |
mainPanel( | |
uiOutput("pdfview") | |
) | |
) | |
)) | |
server <- shinyServer(function(input, output) { | |
observe({ | |
req(input$file_input) | |
file.copy(input$file_input$datapath,"www", overwrite = T) | |
output$pdfview <- renderUI({ | |
tags$iframe(style="height:600px; width:100%", src="0.pdf") | |
}) | |
}) | |
}) | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment