Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

When viewing a PDF file on GitHub, there seems to be no way to have the browser simply display the file as opposed to downloading it.

None of these links work, and these are the only ones I'm able to get to (or derive from the behaviour of working with source code):

share|improve this question
add comment

1 Answer 1

up vote 7 down vote accepted

Github uses content-disposition: attachment for PDFs, which downloads the file automatically on github.com. You can host the file on a static page provided by GitHub which can link to this file and update as you update the PDF. For that, you can see github pages.

Summary

  • Create a repo named USERNAME.github.io.
  • In that repo, click Settings then click Automatic Page Generator, then complete the wizard to publish a User Page.
  • Go back to your content repo and click Settings then click Automatic Page Generator, then complete the wizard to publish a Project Page. (Logically, the project page's files would go in a special directory but GitHub puts them in a gh-pages branch. Don't merge that branch to/from master.)
  • Sync the gh-pages branch to your computer then copy in your PDFs:

    git checkout gh-pages
    git checkout master -- 'docs/*.pdf'

  • Commit the changes and push them to GitHub.
  • Now go back to the repo on GitHub and use the Automatic Page Generator to edit the Project Page, adding links to these PDFs of the form:

    [Intro.pdf](http://USERNAME.github.io/REPONAME/docs/Intro.pdf).

  • Republish the Project Page.
share|improve this answer
    
Using Pages is actually a pretty clever work-around! If there is no other way around this by noon tomorrow, this will be good enough. :) –  Sean Allred Aug 17 '13 at 4:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.