使用 html 链接到 pdf 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36899940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 13:11:40  来源:igfitidea点击:

Linking to a pdf file with html

htmlcsspdfanchorlocal

提问by WoodRobot

LINK

关联

Here is my link I'm keeping my pdf file (path.pdf) in the resources folder and am trying to click this link to open the pdf. When I click it while running local the error is " Your file was not found It may have been moved or deleted."

这是我的链接,我将我的 pdf 文件 (path.pdf) 保存在资源文件夹中,并尝试单击此链接打开 pdf。当我在本地运行时单击它时,错误是“找不到您的文件,它可能已被移动或删除。”

It's clearly there. ive checked, spell checked, and tried changing the location of the pdf file. HTML pages link just fine.

它显然在那里。我检查,拼写检查,并尝试更改pdf文件的位置。HTML 页面链接就好了。

Thanks

谢谢

回答by centanomics

Since you have not clarified for us whether you are using a local host or just viewing the text file in the browser I will assume the latter.

由于您尚未向我们说明您是使用本地主机还是仅在浏览器中查看文本文件,我将假设后者。

In this case, you would have your anchor tag and in the href attribute put the location of the file

在这种情况下,您将拥有锚标记并在 href 属性中放置文件的位置

<a href="C:\Users\Shannon Myers\Documents\Biology-DNA\teen_time_report.pdf">ok</a>

In the above example I started from my C: drive and went from there. Also you could do it as follows:

在上面的例子中,我从我的 C: 驱动器开始,然后从那里开始。你也可以这样做:

<a href="Resources\teen_time_report.pdf">ok</a>

This should link to the pdf file that you have in mind, as long as the resources folder and html file are in the same folder.

只要资源文件夹和 html 文件在同一文件夹中,这应该链接到您想到的 pdf 文件。