I need to build an app where the user can open PDF files within the app -- i.e. not by opening a new browser window. I would need to implement a back button and possibly some overlays over the PDF. Does anyone know if there's a good way to do this in Electron?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you're OK with UI provided by chrome PDF extension you can use it from electron.
See this question
const {app, BrowserWindow} = require('electron')
app.once('ready', () => {
let win = new BrowserWindow({
webPreferences: {
plugins: true
}
})
win.loadURL(__dirname + '/test.pdf')
})
Note, that electron's native PDF support is available only since version 1.6.4
. Before that you can use electron-pdf-window
回答2:
You should checkout gerhardberger's electron-pdf-window