简体   繁体   English

如何使用 django 在浏览器中将 pdf 文件呈现为 pdf

[英]How to render a pdf file as pdf in browser using django

I am using Django web frame work.我正在使用 Django web 框架工作。 I am taking pdf files from users (notes/book/etc).我正在从用户(笔记/书籍/等)那里获取 pdf 文件。 Then I want to display those pdf in website, but I could not find a way.然后我想在网站上显示那些 pdf,但我找不到办法。 Methods that failed 1)iframe 2)simple rendering using django 3)pdf.js library.失败的方法 1)iframe 2)使用 django 3)pdf.js 库的简单渲染。 Also browser blocks rendering initially.浏览器最初也会阻止渲染。 Care to suggest a method and steps to implement it.注意提出实施方法和步骤。

Well the answer has to be very very clear here.那么答案在这里必须非常非常清楚。 You can not display pdf using.您无法使用 pdf 显示。 There is no such library for that.没有这样的图书馆。 Like pdf.js for javascript based frameworks.就像基于 javascript 的框架的 pdf.js 一样。 I have done the research.我已经完成了研究。 So if you want a really good pdf viewer for your django powered website you have to use pdf.js for sure.因此,如果您想要一个非常好的 pdf 查看器用于您的 django 驱动的网站,您肯定必须使用 pdf.js。 I have asked people working with django professionally.我已经问过专业使用 django 的人。

output in firefox output 在 firefox 火狐的输出

ouput in chromium browser铬浏览器中的输出在铬浏览器中输出

Now 2nd output is what we want here is the code现在第二个 output 是我们想要的,这里是代码django代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM