电子静音印刷 [英] Silent printing in electron

查看:40
本文介绍了电子静音印刷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个电子应用程序。我的本地文件系统上有一个PDF,我需要静默打印(在默认打印机上)。我遇到了node-printer库,但是它似乎不适用于我。

I am currently building an electron app. I have a PDF on my local file system which I need to silently print out (on the default printer). I came across the node-printer library, but it doesn't seem to work for me. Is there an easy solution to achieve this?

推荐答案

我最近发布了NPM软件包,用于从Node.js和Electron打印PDF文件。您可以将PDF文件发送到默认打印机或特定打印机。在Windows和类似Unix的操作系统上运行良好: https://github.com/artiebits/pdf -to-printer

I recently published NPM package to print PDF files from Node.js and Electron. You can send a PDF file to the default printer or to a specific one. Works fine on Windows and Unix-like operating systems: https://github.com/artiebits/pdf-to-printer.

易于安装,只需(如果使用纱线):

It's easy to install, just (if using yarn):

yarn add pdf-to-printer

或(如果使用 npm ):

npm install --save pdf-to-printer

然后,将文件静默打印到您执行的默认打印机上:

Then, to silently print the file to the default printer you do:

import printer from "pdf-to-printer";

printer
  .print("assets/pdf-sample.pdf")
  .then(console.log)
  .catch(console.error);

这篇关于电子静音印刷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆