Opening PDF in a browser with Github Pages

后端 未结 8 1704
面向向阳花
面向向阳花 2021-01-31 09:48

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 l

相关标签:
8条回答
  • 2021-01-31 10:37

    I have gone through most of the answers in this section however most of them are hard to figure out or too vague to understand what is happening. There is a simpler way to do this, so in order to display a Pdf file in a browser from Github here is the process:

    Step 1: Make the static website/repository using your Github username for example, if the username is winterishere then repository would be winterishere.github.io

    Step 2: Put the desired pdf in that repository and add an index.html file in the same location as the pdf file eg: resume.pdf.

    Step 3: Open the index.html and add the embed tag to it below:

    <embed src="https://yourusername.github.io/filename.pdf" width="100%" height="850px"/>
    

    in my example the file the code would be:

     <embed src="https://winterishere.github.io/resume.pdf" width="100%" height="850px"/>
    
    0 讨论(0)
  • 2021-01-31 10:40

    Place the PDF file in a folder like; www.website/pdf/example.pdf this will stop the file downloading outside of the root directory.

    The steps are:

    1. Create a new file in main directory.

    2. Name file /pdf/ and save it.

    3. Upload example.pdf file to this folder

    Result:: PDF is viewable at; www.website/pdf/example.pdf

    4. Optional step to avoid the .pdf URL. Create a index.html file in this folder and create a blank html file with PDF embed tag:

    0 讨论(0)
提交回复
热议问题