更新200mm打印
This commit is contained in:
@@ -107,33 +107,33 @@ const PAPER_PRESETS = {
|
||||
'200x200': {
|
||||
labelWidth: 200,
|
||||
labelHeight: 1600,
|
||||
fontSize: 48,
|
||||
lineHeight: 80,
|
||||
cpcl: {
|
||||
pageWidth: 1600, // PAGE-WIDTH(200mm @200dpi = 1600 点),防止右半边被截断
|
||||
gapSense: true, // 使用 GAP-SENSE 自动感应间隙(大标签更稳)
|
||||
fields: [
|
||||
{ x: 384, y: 200 }, // 名称
|
||||
{ x: 384, y: 300 }, // 类别
|
||||
{ x: 384, y: 400 }, // 代码
|
||||
{ x: 960, y: 400 }, // 形态
|
||||
{ x: 384, y: 500 }, // 主要成分
|
||||
{ x: 384, y: 700 }, // 有害成分
|
||||
{ x: 384, y: 896 }, // 注意
|
||||
{ x: 432, y: 1072 }, // 识别码
|
||||
{ x: 512, y: 1168 }, // 单位
|
||||
{ x: 576, y: 1264 }, // 联系
|
||||
{ x: 384, y: 1360 }, // 日期
|
||||
{ x: 960, y: 1360 }, // 重量
|
||||
{ x: 300, y: 1456 }, // 备注
|
||||
{ x: 960, y: 700 } // 标识
|
||||
{ x: 344, y: 256, mag: [2, 2], bold: 0.0, font: 1 }, // 名称
|
||||
{ x: 344, y: 360, mag: [2, 2], bold: 0.0, font: 1 }, // 类别
|
||||
{ x: 344, y: 448, mag: [2, 2], bold: 0.5, font: 0 }, // 代码(加粗)
|
||||
{ x: 912, y: 448, mag: [2, 2], bold: 0.0, font: 1 }, // 形态
|
||||
{ x: 344, y: 544, mag: [2, 2], bold: 0.5, font: 0 }, // 主要成分(加粗)
|
||||
{ x: 344, y: 744, mag: [2, 2], bold: 0.5, font: 0 }, // 有害成分(A401 无,按左列节奏补)
|
||||
{ x: 344, y: 936, mag: [2, 2], bold: 0.0, font: 1 }, // 注意
|
||||
{ x: 392, y: 1128, mag: [2, 2], bold: 0.0, font: 1 }, // 识别码
|
||||
{ x: 480, y: 1224, mag: [2, 2], bold: 0.0, font: 1 }, // 单位(A401 无,按左列节奏补)
|
||||
{ x: 552, y: 1328, mag: [2, 2], bold: 0.0, font: 1 }, // 联系
|
||||
{ x: 352, y: 1432, mag: [2, 2], bold: 0.5, font: 0 }, // 日期(加粗)
|
||||
{ x: 912, y: 1432, mag: [2, 2], bold: 0.0, font: 1 }, // 重量
|
||||
{ x: 240, y: 1528, mag: [2, 2], bold: 0.0, font: 1 }, // 备注
|
||||
{ x: 1432, y: 544, mag: [4, 4], bold: 0.0, font: 1 } // 标识(√ 勾选,4 倍放大)
|
||||
],
|
||||
qrCode: { x: 1248, y: 1168, size: 4 }
|
||||
qrCode: { x: 1220, y: 1224, size: 8, prefix: 'BARCODE QR' }
|
||||
},
|
||||
tspl: {
|
||||
startX: 40,
|
||||
startX: 56,
|
||||
startY: 40,
|
||||
lineHeight: 50,
|
||||
fontSize: '4',
|
||||
qrCode: { x: 300, y: 800, size: 5 }
|
||||
qrCode: { x: 328, y: 776, size: 5 }
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -651,16 +651,33 @@ class BluetoothPrinterService {
|
||||
commands.push(`! 0 200 200 ${labelHeight} 1`);
|
||||
commands.push(sizeCmd);
|
||||
|
||||
// 200x200 等需要显式声明页宽(避免右半部分被截断);其余预设不输出
|
||||
if (layout && layout.pageWidth) {
|
||||
commands.push(`PAGE-WIDTH ${layout.pageWidth}`);
|
||||
}
|
||||
// 大标签用 GAP-SENSE 自动感应间隙;其余预设保持原有 GAP 2mm
|
||||
if (layout && layout.gapSense) {
|
||||
commands.push('GAP-SENSE');
|
||||
} else {
|
||||
commands.push(gapCmd);
|
||||
}
|
||||
|
||||
fieldOrder.forEach((field, index) => {
|
||||
if (data[field]) {
|
||||
const { x, y } = conf[index];
|
||||
commands.push(`T 1 0 ${x} ${y} ${data[field]}`);
|
||||
const f = conf[index] || {};
|
||||
const mag = f.mag || [1, 1]; // 默认 1 倍(兼容 100x100)
|
||||
const bold = (f.bold != null) ? f.bold : 0.0;
|
||||
const font = f.font || 1;
|
||||
commands.push(`SETMAG ${mag[0]} ${mag[1]}`);
|
||||
commands.push(`SETBOLD ${bold}`);
|
||||
commands.push(`T ${font} 0 ${f.x} ${f.y} ${data[field]}`);
|
||||
}
|
||||
});
|
||||
|
||||
if (data.qrcode) {
|
||||
const qrc = (layout && layout.qrCode) || { x: 624, y: 584, size: 4 };
|
||||
commands.push(`B QR ${qrc.x} ${qrc.y} M 2 U ${qrc.size}`);
|
||||
const qrc = (layout && layout.qrCode) || { x: 624, y: 584, size: 4, prefix: 'B QR' };
|
||||
const qrPrefix = qrc.prefix || 'B QR';
|
||||
commands.push(`${qrPrefix} ${qrc.x} ${qrc.y} M 2 U ${qrc.size}`);
|
||||
commands.push(`L0,${data.qrcode}\r\n`);
|
||||
commands.push('ENDQR');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user