是否可以使用node.js打印图像? [英] is it possible to print an image with node.js?

查看:142
本文介绍了是否可以使用node.js打印图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,所以我试图从网页上打印(典型的打印"按钮,但我不希望出现打印对话框),所以我决定使用已经存在的node.js后端进行打印任务(主要是因为如果没有打印对话框,从浏览器进行打印几乎是不可能的).

Ok, so I'm trying to print from a webpage (the typical "print" button, but I don't want the print dialog to appear) so I decided to use my already existing node.js backend to do the task (mainly because printing from browser is nearly impossible without the printing dialog).

我找到了节点打印机( https://github.com/tojocky/node-printer)模块,效果很好,但仅适用于文本.我尝试发送RAW数据,但它的工作是打印原始字符.我真正需要的是打印徽标以及一些转弯信息(这是用于客户服务机构).

I found the node-printer (https://github.com/tojocky/node-printer) module, and it works great, but only with text. I tried to send RAW data, but what it does is printing the raw characters. What I actually need is to print a logo, along with some turn information (this is for a customer care facility).

此外,打印机必须安装在本地,所以我不能使用IPP.

Also, the printer must be installed locally, so I can't use IPP.

是否有任何方法可以打印图像,或者将图像和文本与node.js结合使用?可以通过node-printer完成还是有另一种方法?

Is there any way to print an image, or a combination of images and text with node.js? can it be done through node-printer or is there another way?

推荐答案

我结束了调用exe为我完成工作.我使用child_process来调用 printhtml ,这将为我完成所有打印工作.我的代码以这种方式结束:

I ended calling an exe to do the work for me. I use a child_process to call printhtml, which does all the printing work for me. My code ended this way:

var exec = require('child_process').exec;
exec('printhtml.exe file=file.html', function(err, data) {  
    console.log(data.toString());                       
}); 

这篇关于是否可以使用node.js打印图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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