简体   繁体   English

Print.JS - 设置默认打印设置

[英]Print.JS - set default print settings

I am trying to implement a print PDF option in an application.我正在尝试在应用程序中实现打印 PDF 选项。 I found print.js and looks like this may help.我找到了 print.js,看起来这可能有帮助。 However, I want to set default print options to make sure it prints to the correct scale (ie. 100%).但是,我想设置默认打印选项以确保打印到正确的比例(即 100%)。 Can print.js do this? print.js 可以做到这一点吗? If not, does anyone have a suggestion on how to accomplish this?如果没有,有人对如何实现这一点有建议吗?

Not sure if this can be achieved straight forward or not.不确定这是否可以直接实现。 However there is a workaround for which you need to follow these steps:但是,有一个解决方法,您需要执行以下步骤:

  1. Convert your pdf files in base64 format将 pdf 文件转换为base64 格式
  2. Convert your base64 pdf to base64 png using pdf.js使用pdf.jsbase64 pdf转换为base64 png
  3. Render base64 pngs as html in img tag where you application related styles like margin, scales, etc. can be applied在 img 标签中将 base64 png 渲染为 html 您可以应用与 styles 相关的应用程序,例如边距、比例等
  4. Print your html content with print.js使用print.js打印您的 html 内容

You can check this article solving similar type of problem https://medium.com/@vicky.sharma8127344/print-single-or-multiple-files-with-print-js-and-pdf-js-ab9c8347a309您可以查看这篇解决类似问题的文章https://medium.com/@vicky.sharma8127344/print-single-or-multiple-files-with-print-js-and-pdf-js-ab9c8347a309

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

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