小编Gri*_*don的帖子

使用Electron JS打印PDF文件

我正在尝试创建一个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有同样的经历?

javascript printing pdf node.js electron

22
推荐指数
3
解决办法
1万
查看次数

标签 统计

electron ×1

javascript ×1

node.js ×1

pdf ×1

printing ×1