python 打开pdf显示在页面_Django / Python:在模板中显示pdf
I'm using django 1.8 in python 2.7.I want to show a pdf in a template.Up to know, thanks to MKM's answer I render it in a full page.Do you know how to render it?Here is my code:def userManual(request)
I'm using django 1.8 in python 2.7.
I want to show a pdf in a template.
Up to know, thanks to MKM's answer I render it in a full page.
Do you know how to render it?
Here is my code:
def userManual(request):
with open('C:/Users/admin/Desktop/userManual.pdf', 'rb') as pdf:
response = HttpResponse(pdf.read(), content_type='application/pdf')
response['Content-Disposition'] = 'inline;filename=some_file.pdf'
return response
pdf.closed
解决方案
The ability to embed a PDF in a page is out of the scope of Django itself, you are already doing all you can do with Django by successfully generating the PDF, so you should look at how to embed PDFs in webpages instead:
Therefore, please check:
更多推荐
所有评论(0)