Reputation: 45
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!
Upvotes: 2
Views: 5918
Reputation: 4440
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
Upvotes: 7