7

I have a posts page which stores every individual blog. And each blog has a pdf file. I can upload the pdf via the blog page but when I execute my code through the for-loop on posts - post.file_doucment_path it just shows the pdf file location. Do I need to add a seperate js pdf reader package to get it working? Cheers.

kcuhcx2
  • 343
  • 1
  • 4
  • 15

1 Answers1

17

HTML5 <object> element can embed PDFs in a page without an external library.

<object data="the.pdf" width="1000" height="1000" type='application/pdf'/>

Just replace "the.pdf" with your file document path with Jekyll syntax.

e.g.
<object data="{{ post.file_document_path }}" width="1000" height="1000" type='application/pdf'/>

Jack Leahy
  • 481
  • 4
  • 7
  • 2
    Don't forget to close the object tag. Correct syntax is ``. See https://www.w3.org/TR/html50/embedded-content-0.html#the-object-element – David Jacquel Jul 10 '19 at 09:01