简体   繁体   English

如何在我的R闪亮应用程序中添加一个链接以在新窗口中打开pdf文件?

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

I can use a() to add a hyperlink in to an external site from my Shiny app, 我可以使用a()从我的Shiny应用程序中添加到外部站点的超链接,

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

but how do I make a link to open a pdf (or similar) file? 但是如何建立一个打开pdf(或类似)文件的链接? 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 添加指向R Shiny Application的链接,以便在新的浏览器选项卡中打开链接

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? 但我不知道如何构建href部分 - 我将文件放在哪里打开,如何指定其位置? 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. 我尝试过简单的事情,如http:/// C:/Folder/file.pdf或file:/// C:/Folder/file.pdf,但文件未找到或不会打开。

I am new to shiny and have no html experience, so any suggestions greatly appreciated. 我是新手,没有html的经验,所以任何建议都非常感谢。

Thanks 谢谢

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 ) 将pdf文件放在“www”目录中(它必须是存在ui.rserver.r的目录中的子目录)

then you can run your shiny with: 然后你可以运行你的闪亮:

a("click on me",target="_blank",href="myfile.pdf")

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

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