修复双面打印

This commit is contained in:
xianyi
2025-12-11 15:16:38 +08:00
parent aa330e8167
commit 7eca0e9bf1

View File

@@ -301,9 +301,11 @@ ipcMain.handle("print-pdf", async (event, pdfDataOrUrl, printOptions = {}) => {
}
const duplexMode = printOptions?.duplex;
// pdf-to-printer 使用 side 选项,而不是 duplex
// side 可选值: "simplex" | "duplex" | "duplexshort" | "duplexlong"
const sideOption = duplexMode ? "duplex" : "simplex";
log.info(
`准备打印PDF: ${pdfFilePath}, 打印机: ${
targetPrinterName || "默认打印机"
`准备打印PDF: ${pdfFilePath}, 打印机: ${targetPrinterName || "默认打印机"
}, 双面打印: ${duplexMode ? "是" : "否"}`
);
@@ -311,7 +313,7 @@ ipcMain.handle("print-pdf", async (event, pdfDataOrUrl, printOptions = {}) => {
const printOptions_ptp = {
printer: targetPrinterName || undefined,
silent: true, // 静默打印
duplex: duplexMode || false, // 双面打印选项
side: sideOption, // 双面打印选项
};
await ptp.print(pdfFilePath, printOptions_ptp);