1

I am trying to embed a PDF viewer in my github pages site, so visitors can see my CV and download it. I don't want a hyperlink to the pdf, but to actually have it interactive in the page (like this).

I'm embedding with the line:

<embed src="https://github.com/username/username.github.io/blob/master/CV.pdf" class="application/pdf" width = "100%" height="100%" /> 

But when I navigate to the page (username.github.io/cv/, it only displays the error:

"Blocked by Content Security Policy

An error occurred during a connection to github.com.

Firefox prevented this page from loading in this way because the page has a content security policy that disallows it."

If I try and open the page in Chromium, it's just blank.

I've tried everything described here: Opening PDF in a browser with Github Pages

1 Answers1

1

Since you are using <embed>, all browsers will show you a CSP error, Chromium will probably have an error thrown in the dev console. For more info check this link

I'll assume you have an index.html page which have your <embed> line above.

The issue is that you are embedding a link to the github page that has CV.pdf, i.e. you added a link to another HTML. Instead of doing so, you need to link it to the raw pdf inside your src. You can get the correct url by going to the Github page that has your CV.pdf, right click on Download and then Copy Link Address and use it in your src.

Has Nah
  • 31
  • 2