在带有Github Pages的浏览器中打开PDF [英] Opening PDF in a browser with Github Pages
问题描述
我正在使用GitHub Pages托管我的网站.我有一个PDF文件,希望访问者能够直接在浏览器中打开.但是,当我将PDF文件上传到GitHub Pages并链接到它时,它将在GitHub的查看器中打开.有什么方法可以在浏览器中打开PDF吗?我不想将文档上传到保管箱或Google云端硬盘,因为某些国家/地区不提供这些服务.
I am using GitHub Pages to host my website. I have a PDF file that I want visitors to be able to open directly in a browser. But when I upload the PDF file to GitHub Pages and link to it it opens in GitHub's viewer. Is there any way to open the PDF in a browser? I do not want to upload the document to dropbox or Google Drive as these services are not available in certain countries.
使用原始URL将导致下载.但是我想在浏览器中打开文件.
Using a raw URL would lead to download. But I would like to have the file open in the browser.
推荐答案
假设您的个人网站托管在Github页面中,如下所示:
Suppose your personal website is hosted in a Github page as follows:
https://username.github.io
存储库的名称应为 username.github.io .如果您有一个名为 document.pdf 的pdf文件,并将其放置在文件夹目录中,则应该可以通过以下链接直接在浏览器中打开它:
The repository should be name as username.github.io. If you have a pdf file named document.pdf and you place it in the directory folder then you should be able to open it directly in the browser through the following link:
https://username.github.io/folder/document.pdf
要允许用户在浏览器的新窗口中打开pdf,可以使用以下HTML,其中"PDF"指向链接:
To allow the user to open the pdf in a new window in the browser, you may use the following HTML, where "PDF" points to the link:
<a href="username.github.io/folder/document.pdf" target="_blank">PDF.</a>
这篇关于在带有Github Pages的浏览器中打开PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!