简体   繁体   English

使用 Nodejs 打印 Base64 字符串?

[英]Print Base64 string using Nodejs?

I used the html2pdf npm package to send a base64 string of a pdf to my nodejs server.我使用html2pdf npm 包将 pdf 的 base64 字符串发送到我的 nodejs 服务器。 I then use Nodemailer to send that pdf to an email address setting nodeMailer property like:然后我使用 Nodemailer 将该 pdf 发送到电子邮件地址,设置 nodeMailer 属性,例如:

let mailOptions = {
        from: '"Nodemailer contact" <foo@example.com>', // sender address
        to: 'abc@gmail.com', // list of receivers
        subject: 'Node contact request', // Subject line
        text: 'Hello world?', // plain text body
        html: output, // html body
        attachments: [{
            filename: 'new.pdf',
            content: encodedpdf,
            encoding: 'base64'
          }]

    };

Now, I also want to print this PDF that is encoded Base 64 string to a windows printer using Nodejs.现在,我还想使用 Nodejs 将这个编码为 Base 64 字符串的 PDF 打印到 Windows 打印机。 I have tried googling a way to do this but could not find anything useful.我试过用谷歌搜索一种方法来做到这一点,但找不到任何有用的东西。

There is a node-printer but I believe it does not support the latest Node.有一个节点打印机,但我相信它不支持最新的 Node.js打印机 I used it once in the past and it kinda worked.我过去用过一次,效果不错。 It's supposed to work on Windows.它应该在 Windows 上工作。 In order to print a PDF, you need to convert it to EMF format and then you can print it .要打印 PDF,您需要将其转换为 EMF 格式,然后才能打印 Although there is a node-podium package which simplifies that, it's apparently not maintained anymore.尽管有一个node-podium包可以简化它,但它显然不再维护。

You might get more luck in installing some command line tools and calling them from Node.安装一些命令行工具并从 Node.js 调用它们可能会更幸运。

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

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