Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a link to open a pdf file in a new window from my R shiny app?

Tags:

r

shiny

I can use a() to add a hyperlink in to an external site from my Shiny app,

a("google",href="http://www.google.com")

but how do I make a link to open a pdf (or similar) file? Seems like it should be simple, but I can't find any examples. My question is similar to this one:

Add link to R Shiny Application so link opens in a new browser tab

but I don't know how to structure the href part- where do I put the file to be opened and how do I specify its location? I've tried simple things like http:///C:/Folder/file.pdf or file:///C:/Folder/file.pdf but the file is either not found or wont open.

I am new to shiny and have no html experience, so any suggestions greatly appreciated.

Thanks

like image 439
jim Avatar asked Apr 29 '15 07:04

jim


People also ask

Can I turn a PDF into a clickable Link?

Click on Tools > Edit PDF > Link. Then select "Add/Edit Web or Document Link. Next, drag a box to where you want to add the hyperlink to. Last, save the file, and it will add the hyperlink to the document.


1 Answers

Put the pdf file inside the "www" directory (it has to be a subdirectory inside the directory where there are ui.r and server.r )

then you can run your shiny with:

a("click on me",target="_blank",href="myfile.pdf")
like image 182
dax90 Avatar answered Oct 05 '22 08:10

dax90