Hi!
I have a Rshiny app with various tabpanels, and in one of the tabpanels i want to display certain pages of a PDF file and i wuould like to know how i can do this.
For now I have simply tried to add the PDF file to a tab and have seen the following codes:
(Upload and view a PDF in Shiny)
(https://stackoverflow.com/questions/48194513/binary-file-read-and-write-in-shiny)
For the server:
observe({
req(input$file1)
test_file <- readBin(con=input$file1$datapath,what = 'raw',n=input$file1$size)
writeBin(test_file,'www/myreport.pdf')
})
output$pdfview <- renderUI({
tags$iframe(style="height:600px; width:100%", src="myreport.pdf")
})
OR
observe({
raw <- readBin(input$file1$datapath, what="raw")
zz <- file("testbin", "wb")
writeBin(raw, zz)
})
output$pdfview <- renderUI({
tags$iframe(style="height:600px; width:100%", src=zz)
})
And the Ui as:
tabPanel('Estructura de Derivados Texto', uiOutput("pdfview")),
None of these two codes seem to work for me, the first server input tells me: Warning in file(con, "wb") :cannot open file 'www/myreport.pdf': No such file or directory, and the second one tells me that is an Error in readBin:invalid connection.
If anyone has any ideas how i can fix it and also to later make it more complicated and only display some of the pages it would be of great help!
Thank you!