链接以从文件夹打开PDF [英] Link to open PDF from folder

查看:94
本文介绍了链接以从文件夹打开PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的计算机上的文件夹中有一些PDF,是否可以编写链接以将其打开到网页上?

I have some PDF's sitting in a folder on my computer, is there a way to write a link to open them on to a webpage?

主要思想是,当该网站上线时,该链接将用于从该文件夹下载pdf,但是显然,在稍后阶段,该文件夹将是我网站上的一个临时文件夹.

The main idea is when the site goes live the link will be used to download the pdfs from the folder, but obviously at a later stage the folder will be a temp folder on my website.

因此,此刻我只想从链接中打开pdf,最终目标是让链接下载它们.

So at the moment i just want to open the pdfs from a link, and the final goal will be to have the links download them.

有人可以帮助我吗?

这是要链接到我要链接的pdf的文件路径.

This is the file path to get to the pdf i want to link to.

C:\ Users \ Shaun \ Documents \ FormValue \ CS1.pdf

C:\Users\Shaun\Documents\FormValue\CS1.pdf

我将如何创建链接?

推荐答案

如果要链接到PDF,只需要将文件的相对路径放在ahref属性中.标签.假设您有一个名为pdfs的文件夹,其中包含文件boom.pdf,一个名为site的文件夹位于文件文件夹旁边,其中包含文件site.html.然后,您所要做的就是将此链接放在html文件中:

If you want to have a link to a PDF, you just have to put the relative path to the file in the href attribute of an a tag. So let's say you had a folder called pdfs, with the file boom.pdf inside it, and folder called site sitting beside it, with the file site.html in it. Then all you'd have to do is put this link in the html file:

<a href="../pdfs/boom.pdf">Link to a pdf</a>

如今在大多数(所有?)浏览器中,这将在新标签中打开PDF.要下载它,您可以右键单击它并执行Save Link As事情.只需在href中获得正确的路径即可.

In most (all?) browsers now a days, that will open the PDF in a new tab. To download it you would right-click it and do the Save Link As thing. Just need to get the path in href right.

更新

如果要使用文件的完整路径,则需要在文件前加上file://前缀.然后,您只需将其与常规链接一样放在href中,最后添加类似以下内容:

If you want to use the full path to the file, you need to prefix it with file://. Then you just put it in the href the same as with a regular link, ending up with something like:

<a href="file://C:\Users\Shaun\Documents\FormValue\CS1.pdf">Link to a pdf</a>

这应该与您的设置配合使用,但是如果pdf和html文件彼此靠近存储,则相对URL仍然是一个不错的选择. Google的一些工作应向您展示如何编写这些内容.

This should work with your set up, but if the pdf and the html files are stored near each other, relative URLs are still a good option. A little bit of Google work should show you how to write those.

这篇关于链接以从文件夹打开PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆