使用 Github Pages 在浏览器中打开 PDF [英] Opening PDF in a browser with Github Pages

查看:147
本文介绍了使用 Github Pages 在浏览器中打开 PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 GitHub Pages 来托管我的网站.我有一个 PDF 文件,我希望访问者能够直接在浏览器中打开它.但是当我将 PDF 文件上传到 GitHub Pages 并链接到它时,它会在 GitHub 的查看器中打开.有没有办法在浏览器中打开PDF?我不想将文档上传到 Dropbox 或 Google Drive,因为这些服务在某些国家/地区不可用.

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屋!

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