我正在使用这个库Electron Pos Printer,并且我已经制作了一小批代码。我已成功连接 POS 热敏打印机,但当我发送打印命令时,它仅“打印”少量空白纸。关于解决这个问题有什么想法,或者推荐其他一些库吗?
let printerName = "myprinter";
let widthPage = "155";
const data = [
{
type: "text", // 'text' | 'barCode' | 'qrCode' | 'image' | 'table
value: "This is sample print job",
style: `text-align:center;font-size:16px;`,
},
{
type: "qrCode",
value: "https://github.com/fssonca",
height: 55,
width: 55,
style: "margin-left:50px",
},
];
PosPrinter.print(data, {
preview: false, // Preview in window or print
width: widthPage, // width of content body
margin: "0 0 0 0", // margin of content body
copies: 1, // Number of copies to print
printerName: printerName, // printerName: string, check it at webContent.getPrinters()
timeOutPerLine: 400,
silent: true,
}).catch((err) => console.log(err));
安装:
let widthPage = "155";
尝试:
widthPage="155px"
我遇到了同样的问题,我所做的对我有用的是
PosPrinter.print(data, {
...
silent: false,
}).catch((err) => console.log(err));