我正在尝试创建一个Electron JS应用程序,其目的是打印字母大小的PDF.
这是我的打印代码片段:
win = new BrowserWindow({
width: 378,
height: 566,
show: true,
webPreferences: {
webSecurity: false,
plugins: true
}
});
// load PDF
win.loadURL('file://' + __dirname + '/header1_X_BTR.pdf');
// if pdf is loaded start printing
win.webContents.on('did-finish-load', () => {
win.webContents.print({silent: true, printBackground:true});
});
Run Code Online (Sandbox Code Playgroud)
我的问题是:如果我让print({silent:true})
我的打印机打印一个空页面.如果有print({silent:false})
,打印机的打印方式与屏幕截图相同,包括标题,控件等.
我需要对PDF内容进行静音打印,而且我无法在数天内完成这项工作.有没有人与Electron有同样的经历?