Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Left-clicking a PDF in GitHub should display it in the browser or download it?

I have a PDF hosted in a GitHub directory. I have a link to this PDF in my README.md as follows -

[foo](https://github.com/me/bar_repo/foo.pdf)

so that users can find it easily when they access the repository. However when they click the link instead of opening the PDF in the browser or downloading it, the users is brought to the github page with url - https://github.com/me/bar_repo/foo.pdf - and here they have options to "View Raw", "Open", etc...(and the Open command requires installation of GitHub for windows...sigh).

I simply want to let users view the PDF in the browser or be given the option to download it if they left-click this link, as is usually the case when people click on links for PDFs on the net.

Does anyone know how I can make this happen?

like image 601
sonicboom Avatar asked Apr 08 '14 12:04

sonicboom


People also ask

Can GitHub display PDF?

GitHub supports rendering of PDF documents.

How do I download a PDF from GitHub?

Click on the file you wish to download from GitHub to open the individual file. From here, right click the Raw button at the top of the file, select Save Link As… , choose the location on your computer where you want to save the file, and select Save .

How do I download documents from GitHub?

To download from GitHub, you should navigate to the top level of the project (SDN in this case) and then a green "Code" download button will be visible on the right. Choose the Download ZIP option from the Code pull-down menu. That ZIP file will contain the entire repository content, including the area you wanted.


2 Answers

You need to link to the raw version. So on the resulting page, context click the Raw button, and choose Copy link address and use that URL in your README.

like image 58
Joel Glovier Avatar answered Oct 09 '22 17:10

Joel Glovier


A simpler option should be available since March 17th, 2015:
"PDF Viewing"

Simply browse to a PDF document and we'll render it in your browser like any other file.
From presentations to papers, we've got you covered.
Many thanks to Mozilla and every contributor to PDF.js.

https://cloud.githubusercontent.com/assets/2546/6703741/cbb216c0-ccfc-11e4-9c15-ecb6a33e8ddb.gif

like image 1
VonC Avatar answered Oct 09 '22 17:10

VonC