0

My problem is that the browser downloads the pdf instead of displaying it.

I tried some solutions from this site (for example) but none of them worked for me.

I use this code in my html file and nothing else:

{% load static %}
<body>
    <object data="test.pdf" type="application/pdf" title="SamplePdf" width="500" height="720">
        <embed src="{% static 'test.pdf' %}" >
    </object>
</body>

Ideas?

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77

1 Answers1

0

Displaying PDF has nothing in common with Django, you can handle it with pure HTML:

Recommended way to embed PDF in HTML?

Have you tried:

<embed src="{% static 'test.pdf' %}" width="500" height="375" 
 type="application/pdf">

?

rafaljusiak
  • 1,050
  • 1
  • 10
  • 17
  • i found what's the problem. its because i use IDM to download files and IDM has a default settings to download pdf files directly. when i changed them.it works fine – brain.doubt May 11 '20 at 12:55