admin管理员组

文章数量:1295874

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?

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?

Share asked Aug 25, 2017 at 5:04 David J.David J. 1,91313 gold badges52 silver badges100 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

If you're OK with UI provided by chrome PDF extension you can use it from electron.

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 and has been broken from 3.0.0 until 9.0.0. (See this answer for details) For versions without support you can use electron-pdf-window

You should checkout gerhardberger's electron-pdf-window

本文标签: javascriptopening pdf files in electronStack Overflow