@bluetooth/print-plugin
v1.0.2
Published
蓝牙打印指令生成工具
Downloads
4
Readme
Install
npm install @bluetooth/print-plugin
Usage
import { decodeTemplate } from "@bluetooth/print-plugin"
const template = {
dpi: "203", // 打印机分辨率
cmdType: "esc",
command: [
{
type: "text",
scale: "1.5", // 1: 标准宽高, 1.5: 高放大两倍, 2: 宽高同时放大两倍
margin: {
left: "16",
right: "16",
},
content: "${title1}",
textAlign: "center", // 居中显示,默认左对齐
},
{
type: "fillAround",
margin: {
left: "3",
right: "3",
},
text: "货品信息",
isStatic: true,
offsetY: "1",
continuePreY: true,
},
{
type: "command",
command: [
{
type: "text",
group: "1",
scale: "1.5",
margin: {
left: "3",
right: "50",
},
content: "${indexGoodsName}",
offsetY: "3",
continuePreY: true,
},
{
type: "text",
group: "1",
scale: "1",
margin: {
left: "3",
right: "3",
},
offsetY: "4",
label: "数量:",
content: "${quantityWeight}",
continuePreY: true,
},
{
type: "text",
group: "1",
scale: "1",
margin: {
left: "36",
right: "3",
},
label: "单价:",
content: "${price}",
samePreY: true,
},
{
type: "text",
group: "1",
scale: "1",
margin: {
left: "3",
right: "3",
},
content: "${itemRemark}",
offsetY: "1",
ignoreLen: true,
continuePreY: true,
},
],
},
],
pageWidth: "75",
}
const printData = {
buyerName: "测试客户",
title1: "广东省食用农产品批发市场销售票据",
items: [
{
indexGoodsName: "1.示例胡萝卜",
price: "5",
amount: "20",
quantityWeight: "4件",
itemRemark: "",
},
{
indexGoodsName: "2.示例土豆",
price: "4",
amount: "0",
quantityWeight: "0公斤",
itemRemark: "",
},
],
}
const data = await decodeTemplate(template, printData)
console.log(data)