简体   繁体   English

如何使用 Javascript 打印输出流 PDF

[英]How to print outputstream PDF using Javascript

I'm getting PDF file as output stream and want to print it using Javascript .我正在获取 PDF 文件作为输出流,并希望使用Javascript打印它。 There're some tips about printing PDF file or iframe.有一些关于打印 PDF 文件或 iframe 的提示。 But I need to print PDF files that is generated by server after print request.但是我需要在打印请求后打印服务器生成的 PDF 文件。

JavaScript can't access any local resources like the file system or attached printers, so this isn't possible directly. JavaScript 无法访问任何本地资源,如文件系统或连接的打印机,因此无法直接访问。

What you need is to convert the PDF to, say, HTML5.您需要的是将 PDF 转换为 HTML5。 Then display that in your browser and call document.print() to print it.然后在浏览器中显示它并调用document.print()来打印它。

The project pdf.js already does a pretty good job to convert PDF to HTML.项目pdf.js在将 PDF 转换为 HTML方面已经做得很好。

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

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