Ellie
Ellie

Reputation: 415

Embed PDF to shiny app

I don't really know where to begin with this - I have a file that is akin to an appendix that I want made available to my shiny app users. Is possible to embed a PDF from my local drive in to my shiny app & if so is there an ability to have the pdf icon built in? Meaning when you click the pdf icon, you'd download the file specified in the code.

Any help is appreciated!!

Upvotes: 4

Views: 972

Answers (1)

Stéphane Laurent
Stéphane Laurent

Reputation: 84719

Assuming you have a pdf icon file pdficon.png and a pdf file mypdf.pdf, put them in the subfolder www. Then in your app:

library(shiny)

ui <- fluidPage(
  tags$a(tags$img(src="pdficon.png"), href="mypdf.pdf", download="pdfname.pdf")   
)

server <- function(input, output) {
}

shinyApp(ui = ui, server = server)

Then clicking on the icon will download the pdf file under the new name pdfname.pdf.

Upvotes: 6

Related Questions