双面打印

This commit is contained in:
xianyi
2025-12-08 14:48:38 +08:00
parent 0b6fdcf95f
commit 2ba570a504
4 changed files with 67 additions and 4 deletions

View File

@@ -300,16 +300,18 @@ ipcMain.handle("print-pdf", async (event, pdfDataOrUrl, printOptions = {}) => {
throw new Error(`PDF文件大小异常${stats.size} bytes可能文件损坏`);
}
const duplexMode = printOptions?.duplex;
log.info(
`准备打印PDF: ${pdfFilePath}, 打印机: ${
targetPrinterName || "默认打印机"
}`
}, 双面打印: ${duplexMode ? "是" : "否"}`
);
// 使用 pdf-to-printer 打印
const printOptions_ptp = {
printer: targetPrinterName || undefined,
silent: true, // 静默打印
duplex: duplexMode || false, // 双面打印选项
};
await ptp.print(pdfFilePath, printOptions_ptp);