fix: 🧩 修复打印字体穿透

This commit is contained in:
2025-08-13 10:15:56 +08:00
parent 618666421e
commit 00be3968f9
14 changed files with 54 additions and 38 deletions

View File

@@ -9,7 +9,7 @@ export const numberCodePrint = async (list, callBack) => {
LODOP.SET_PRINT_STYLE("GraphicsMode", 0);
LODOP.SET_PRINT_PAGESIZE(0, 875, 200, "A4");
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 7);
let code69Img = set69Code(list[0].barCode);
// 循环打印条码,每页打印两个
@@ -56,6 +56,7 @@ function printLeftContent(item, code69Img) {
if (specifications) {
LODOP.ADD_PRINT_TEXT(4, 15, "100%", 10, specifications);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
}
//SN码和底部文字
if (numberCode && numberCode !== " ") {
@@ -87,6 +88,7 @@ function printRightContent(item, code69Img) {
if (specifications) {
LODOP.ADD_PRINT_TEXT(4, 177, "100%", 10, specifications);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
}
//SN码和底部文字
@@ -98,5 +100,6 @@ function printRightContent(item, code69Img) {
//底部文字(SN码)
LODOP.ADD_PRINT_TEXT(66, 195, 140, 10, numberCode);
LODOP.SET_PRINT_STYLEA(0, "LetterSpacing", 4);
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
}
}

View File

@@ -9,7 +9,7 @@ export const numberCodePrint = async (list, callBack) => {
LODOP.SET_PRINT_STYLE("GraphicsMode", 0);
LODOP.SET_PRINT_PAGESIZE(0, 875, 200, "A4");
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 7);
let code69Img = set69Code(list[0].barCode);

View File

@@ -9,7 +9,7 @@ export const numberCodePrint10 = async (list, callBack) => {
LODOP.SET_PRINT_STYLE("GraphicsMode", 0);
LODOP.SET_PRINT_PAGESIZE(0, 875, 100, "A4");
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 7);
// 循环打印条码,每页打印两个
for (let i = 0; i < list.length; i += 2) {

View File

@@ -9,7 +9,7 @@ export const numberCodePrint10 = async (list, callBack) => {
LODOP.SET_PRINT_STYLE("GraphicsMode", 0);
LODOP.SET_PRINT_PAGESIZE(0, 875, 100, "A4");
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 7);
// 循环打印条码,每页打印两个
for (let i = 0; i < list.length; i += 2) {

View File

@@ -13,7 +13,7 @@ export const oneCodePrint = (list, callBack) => {
LODOP.PRINT_INIT("打印序列码");
LODOP.SET_PRINT_PAGESIZE(0, 600, 400);
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 10);
LODOP.On_Return_Remain = true;
// 循环打印条码,每页打印两个 += 2
@@ -55,8 +55,9 @@ function printContent(item, code69Img, date) {
if (specifications) {
console.log(specifications); //${测试}
const HTML = `<div
style="text-align:center;width:210px;white-space: nowrap; overflow: hidden;font-size:13px;font-family:思源黑体;font-weight:900;">${specifications}</div>`;
style="text-align:center;width:210px;white-space: nowrap; overflow: hidden;font-size:13px;font-family:黑体;font-weight:900;">${specifications}</div>`;
LODOP.ADD_PRINT_HTM(11, 4, 590, 10, HTML);
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
}
//SN码和底部文字
if (serialNumber && serialNumber !== " ") {

View File

@@ -12,7 +12,7 @@ export const oneNumberCodePrint = (list, callBack) => {
LODOP.PRINT_INIT("打印序列码");
LODOP.SET_PRINT_PAGESIZE(0, 600, 400);
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 10);
LODOP.On_Return_Remain = true;
// 循环打印条码,每页打印两个 += 2
@@ -53,7 +53,7 @@ function printContent(item, code69Img) {
//规格型号 border:1px solid red;
if (specifications) {
const HTML = `<div
style="text-align:center;width:210px;white-space: nowrap; overflow: hidden;font-size:13px;font-family:思源黑体;font-weight:900;">${specifications}</div>`;
style="text-align:center;width:210px;white-space: nowrap; overflow: hidden;font-size:13px;font-family:黑体;font-weight:900;">${specifications}</div>`;
LODOP.ADD_PRINT_HTM(11, 4, 590, 10, HTML);
}
//SN码和底部文字

View File

@@ -10,7 +10,7 @@ export const sequenceCodePrint = (list, callBack) => {
LODOP.PRINT_INIT("打印序列码");
LODOP.SET_PRINT_PAGESIZE(0, 875, 200, "A4");
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 7);
LODOP.On_Return_Remain = true;
// 循环打印条码,每页打印两个
@@ -57,6 +57,8 @@ function printLeftContent(item, code69Img, date) {
if (specifications) {
LODOP.ADD_PRINT_TEXT(4, 15, "100%", 10, specifications);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
console.log("到这里");
}
//SN码和底部文字
if (serialNumber && serialNumber !== " ") {
@@ -67,6 +69,7 @@ function printLeftContent(item, code69Img, date) {
LODOP.ADD_PRINT_TEXT(65, 26, 100, 10, serialNumber);
//底部文字(日期)
LODOP.ADD_PRINT_TEXT(65, 125, 40, 10, date);
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
}
}
//右边打印
@@ -88,6 +91,7 @@ function printRightContent(item, code69Img, date) {
if (specifications) {
LODOP.ADD_PRINT_TEXT(4, 177, "100%", 10, specifications);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
}
//SN码和底部文字

View File

@@ -11,7 +11,7 @@ export const sequenceCodePrint = (list, callBack) => {
LODOP.PRINT_INIT("打印序列码");
LODOP.SET_PRINT_PAGESIZE(0, 875, 200, "A4");
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 7);
LODOP.On_Return_Remain = true;
// 获取 SVG 元素用于生成EAN13码

View File

@@ -9,7 +9,7 @@ export const serialNumberPrint = async (list, callBack) => {
LODOP.SET_PRINT_PAGESIZE(0, 875, 100, "");
// LODOP.SET_PRINT_MARGIN(10, 10, 10, 10);
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 7);
// 循环打印条码,每页打印两个
for (let i = 0; i < list.length; i += 2) {
@@ -44,7 +44,7 @@ function printLeftContent(item) {
LODOP.ADD_PRINT_IMAGE(7, 16, 140, 20, '<img src="' + codeSN(serialNumber) + '">'); // 添加图片
LODOP.SET_PRINT_STYLEA(0, "Stretch", 1);
//底部文字(SN码)
LODOP.ADD_PRINT_TEXT(27, 26, 100, 10, "0oo0");
LODOP.ADD_PRINT_TEXT(27, 26, 100, 10, serialNumber);
//底部文字(日期)
LODOP.ADD_PRINT_TEXT(27, 125, 40, 10, dateCreate());
}

View File

@@ -8,7 +8,7 @@ export const serialNumberPrint = async (list, callBack) => {
LODOP.PRINT_INIT("打印序列号");
LODOP.SET_PRINT_PAGESIZE(0, 875, 100, "");
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 7);
let date = dateCreate();
// 循环打印条码,每页打印两个

View File

@@ -10,7 +10,7 @@ export const twoCodePrint = async (printData, callBack) => {
LODOP.SET_PRINT_PAGESIZE(0, 800, 280, "");
// let barCodeClone = "6954301173908";
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 7); //list[0].barCode
let code69Img = set69Code(printData[0].barCode);
@@ -85,7 +85,7 @@ function printLeftContent(item, code69Img) {
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
//border:1px solid red
// const HTMLL = `<div
// style="text-align:center;width:136px;white-space: nowrap; overflow: hidden;font-size:11px;font-family:思源黑体;font-weight:900;">${specifications}</div>`;
// style="text-align:center;width:136px;white-space: nowrap; overflow: hidden;font-size:11px;font-family:黑体;font-weight:900;">${specifications}</div>`;
// LODOP.ADD_PRINT_HTM(4, 4, "100%", 10, HTMLL);
}
//第一件SN码和底部文字
@@ -133,7 +133,7 @@ function printRightContent(item, code69Img) {
LODOP.ADD_PRINT_TEXT(6, 168, "100%", 10, specifications);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2); //border:1px solid red
// const HTMLR = `<div
// style="text-align:center;width:136px;white-space: nowrap; overflow: hidden;font-size:11px;font-family:思源黑体;font-weight:900;">${specifications}</div>`;
// style="text-align:center;width:136px;white-space: nowrap; overflow: hidden;font-size:11px;font-family:黑体;font-weight:900;">${specifications}</div>`;
// LODOP.ADD_PRINT_HTM(4, 158, "100%", 10, HTMLR);
}

View File

@@ -8,7 +8,7 @@ export const boxCodePrint = async (list, callBack) => {
LODOP.PRINT_INIT("打印箱码");
LODOP.SET_PRINT_PAGESIZE(0, 875, 200, "A4");
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
LODOP.SET_PRINT_STYLE("FontSize", 10);
// 循环打印条码,每页打印两个
@@ -44,7 +44,7 @@ function printLeftContent(item) {
LODOP.SET_PRINT_STYLEA(0, "Stretch", 1);
//底部文字(SN码)
// LODOP.ADD_PRINT_TEXT(62, 52, 100, 10, boxBillNo);
let element = `<div style="overflow: hidden;white-space: nowrap;width: 144px;text-align: center;border:font-size:12px;font-weight: bold;font-family:'思源黑体';">${boxBillNo}</div>`;
let element = `<div style="overflow: hidden;white-space: nowrap;width: 144px;text-align: center;border:font-size:12px;font-weight: bold;font-family:'黑体';">${boxBillNo}</div>`;
LODOP.ADD_PRINT_HTM(54, 17, 140, 12, element);
}
}
@@ -58,7 +58,7 @@ function printRightContent(item) {
LODOP.SET_PRINT_STYLEA(0, "Stretch", 1);
//底部文字(SN码)
// / LODOP.ADD_PRINT_TEXT(62, 212, 100, 10, boxBillNo);
let element = `<div style="overflow: hidden;white-space: nowrap;width: 144px;text-align: center;border:font-size:12px;font-weight: bold;font-family:'思源黑体'">${boxBillNo}</div>`;
let element = `<div style="overflow: hidden;white-space: nowrap;width: 144px;text-align: center;border:font-size:12px;font-weight: bold;font-family:'黑体'">${boxBillNo}</div>`;
LODOP.ADD_PRINT_HTM(54, 177, 140, 12, element);
}

View File

@@ -26,7 +26,7 @@ export const boxMarkListPrint = (printData, printNumber) => {
LODOP.SET_PRINT_PAGESIZE(0, 900, 400, "A4");
LODOP.SET_PRINT_STYLE("FontSize", 9.3);
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
let logs = [];
let printDataClone = [];
let resultArray = [];
@@ -95,18 +95,21 @@ function AddPrintContent(obj) {
if (specifications) {
let chinesePattern = /[\u4e00-\u9fa5]/; // 匹配中文字符的正则表达式
if (chinesePattern.test(specifications)) {
LODOP.ADD_PRINT_TEXT(8, 8, "20mm", 10, "产品型号:");
// LODOP.ADD_PRINT_TEXT(8, 8, "20mm", 10, "产品型号:");
//`${specifications} DIP/N-MOS/VS6880AT/T0220/铁封
if (specifications.length > 15) {
// LODOP.ADD_PRINT_TEXT(8, 8, "20mm", 10, "产品型号:");
LODOP.ADD_PRINT_TEXT(8, 8, "20mm", 10, "产品型号:");
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.ADD_PRINT_TEXT(8, 64, "45mm", 20, `${specifications}`);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLE("FontName", "黑体");
//防止文字未满进行换行
LODOP.SET_PRINT_STYLEA(0, "TextNeatRow", 1);
LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -5);
} else {
// LODOP.ADD_PRINT_TEXT(8, 8, "20mm", "10mm", "产品型号:");
LODOP.ADD_PRINT_TEXT(8, 64, "45mm", "100%", `${"ORICO-07000-IN-1TB-GD-BP"}`);
LODOP.ADD_PRINT_TEXT(8, 8, "20mm", "10mm", "产品型号:");
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.ADD_PRINT_TEXT(8, 64, "45mm", "100%", `${specifications}`);
LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -5);
//防止文字未满进行换行
LODOP.SET_PRINT_STYLEA(0, "TextNeatRow", 1);
@@ -114,16 +117,18 @@ function AddPrintContent(obj) {
}
} else {
if (specifications.length > 25) {
// LODOP.ADD_PRINT_TEXT(8, 8, "20mm", 10, "产品型号:");
LODOP.ADD_PRINT_TEXT(8, 64, "45mm", 20, `${"ORICO-07000-IN-1TB-GD-BP"}`);
LODOP.ADD_PRINT_TEXT(8, 8, "20mm", 10, "产品型号:");
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.ADD_PRINT_TEXT(8, 64, "45mm", 20, `${specifications}`);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
//防止文字未满进行换行
LODOP.SET_PRINT_STYLEA(0, "TextNeatRow", 1);
LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -5);
LODOP.SET_PRINT_STYLEA(0, "FontName", "Times New Roman");
} else {
// LODOP.ADD_PRINT_TEXT(8, 8, "20mm", "10mm", "产品型号:");
LODOP.ADD_PRINT_TEXT(8, 64, "45mm", "100%", `${"ORICO-07000-IN-1TB-GD-BP"}`);
LODOP.ADD_PRINT_TEXT(8, 8, "20mm", "10mm", "产品型号:");
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.ADD_PRINT_TEXT(8, 64, "45mm", "100%", `${specifications}`);
//防止文字未满进行换行
LODOP.SET_PRINT_STYLEA(0, "TextNeatRow", 1);
LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -5);
@@ -138,13 +143,13 @@ function AddPrintContent(obj) {
LODOP.ADD_PRINT_TEXT(8, 232, "28mm", 30, `${remark}`);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.SET_PRINT_STYLEA(0, "FontName", "思源黑体");
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -6);
} else {
LODOP.ADD_PRINT_TEXT(8, 232, "28mm", 30, `${remark}`);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.SET_PRINT_STYLEA(0, "FontName", "思源黑体");
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -6);
}
}
@@ -186,7 +191,7 @@ function AddPrintContent(obj) {
//产品名称
if (materialName) {
LODOP.ADD_PRINT_TEXT(37, 8, "20mm", "10mm", "产品名称:");
LODOP.SET_PRINT_STYLEA(0, "FontName", "思源黑体");
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.ADD_PRINT_TEXT(37, 64, "45mm", 20, `${materialName}`);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -4);
@@ -225,15 +230,18 @@ function AddPrintContent(obj) {
let weishuElement = `<div style="font-size:16px;color:#000;font-weight:bold;">尾数</div>
</div>`;
LODOP.ADD_PRINT_HTM(68, 295, "45mm", "100%", weishuElement);
LODOP.SET_PRINT_STYLEA(0, "Angle", 30);
LODOP.ADD_PRINT_ELLIPSE(48, 293, 40, 40, 1, 1);
}
//订单号
if (beginNumber) {
LODOP.ADD_PRINT_TEXT(64, 8, "78mm", 10, `订单号:${orderBillNo}`);
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.SET_PRINT_STYLEA(0, "Overflow", 2);
} else {
LODOP.ADD_PRINT_TEXT(65, 8, "78mm", 10, `订单号:${orderBillNo}`);
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.SET_PRINT_STYLEA(0, "Overflow", 2);
}
@@ -305,17 +313,17 @@ function AddPrintContent(obj) {
}
if (beginNumber) {
let beginNumberStr = `<div style="font-size:12px;color:#000;font-weight:bold;font-family:'思源黑体'">
let beginNumberStr = `<div style="font-size:12px;color:#000;font-weight:bold;font-family:'黑体'">
流水号:${beginNumber}
</div>`;
//LODOP.SET_PRINT_STYLEA(0, "FontName", "思源黑体");
//LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.SET_PRINT_STYLEA(0, "FontName", "Times New Roman");
LODOP.ADD_PRINT_HTM(126, 8, "50mm", "100%", beginNumberStr);
}
if (endNumber) {
let endNumberStr = `<div style="font-size:12px;color:#000;font-weight:bold;font-family:'思源黑体';"><span>${endNumber}</span></div>
let endNumberStr = `<div style="font-size:12px;color:#000;font-weight:bold;font-family:'黑体';"><span>${endNumber}</span></div>
</div>`;
// LODOP.SET_PRINT_STYLEA(0, "FontName", "思源黑体");
// LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.SET_PRINT_STYLEA(0, "FontName", "Times New Roman");
LODOP.ADD_PRINT_HTM(138, 51, "50mm", "100%", endNumberStr);
}

View File

@@ -26,7 +26,7 @@ export const boxMarkListPrint = (printData, printNumber) => {
LODOP.SET_PRINT_PAGESIZE(0, 900, 400, "");
LODOP.SET_PRINT_STYLE("FontSize", 9.3);
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.SET_PRINT_STYLE("FontName", "思源黑体");
LODOP.SET_PRINT_STYLE("FontName", "黑体");
let logs = [];
let printDataClone = [];
@@ -124,13 +124,13 @@ function AddPrintContent(obj) {
LODOP.ADD_PRINT_TEXT(8, 232, "28mm", 30, `${remark}`);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.SET_PRINT_STYLEA(0, "FontName", "思源黑体");
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -6);
} else {
LODOP.ADD_PRINT_TEXT(8, 232, "28mm", 30, `${remark}`);
LODOP.SET_PRINT_STYLEA(0, "TextOverflow", 2);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
LODOP.SET_PRINT_STYLEA(0, "FontName", "思源黑体");
LODOP.SET_PRINT_STYLEA(0, "FontName", "黑体");
LODOP.SET_PRINT_STYLEA(0, "LineSpacing", -6);
}
}