1

I'm really quite new with django and was wondering if there is any way I can show a preview of pdfs/documents inside an html template with django and not another page/tab?

Would like to ask for any insight. Thanks a lot!

fandomfox
  • 35
  • 2
  • 9

1 Answers1

7

Since Django is just a web server you would need to tackle this through HTML In order to preview a PDF if HTML you would need to use the embed tag in the HTML like so.

<embed src="path_of_your_pdf/your_pdf_file.pdf" type="application/pdf" height="700px" width="500">

If the path to your pdf is stored as a variable in your python code what you can do is

<embed src="{{path_to_pdf_file}}" type="application/pdf" height="700px" width="500">

You may also want to check out this question or this question

Marcello B.
  • 4,177
  • 11
  • 45
  • 65