This commit is contained in:
yuchenglong
2025-12-09 13:55:52 +08:00
7 changed files with 101 additions and 6 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);