CcSimple / electron-hiprint

MIT License
67 stars 35 forks source link

能否把浏览器静默打印独立出来,不需要hiprint的模板设计,就是普通的web页面 #4

Closed lovert9999 closed 1 year ago

lovert9999 commented 1 year ago

能否把浏览器静默打印独立出来,不需要hiprint的模板设计,就是普通的web页面

CcSimple commented 1 year ago

可以直接发送 html 到客户端的。

格式如下: {html,templateId}

其中 html 是html字符串

templateId 用于 回调通知,调用方。

仔细看看源码中 print.js 和 print.html 就清楚了。

lovert9999 commented 1 year ago

var html = '

Hello World!

'; socket.emit("news",{html:html,templateId:"",printer:"Microsoft Print to PDF"});显示连接了,但未打印出来

lovert9999 commented 1 year ago

找到原因了,是socket版本低于2.X引起的跨域问题,解决了,因为用chatgpt写的代码,没有看他的cdn引用是低版本的