electron 电子位置打印机打印空白收据

3xiyfsfu  于 2022-12-08  发布在  Electron
关注(0)|答案(1)|浏览(292)

我正在使用这个库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));
5lhxktic

5lhxktic1#

代替:

let widthPage = "155";

试试看:

widthPage="155px"

相关问题