在电子中打开pdf文件 [英] opening pdf files in electron

查看:106
本文介绍了在电子中打开pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要构建一个应用程序,使用户可以在该应用程序内打开PDF文件-即,无需打开新的浏览器窗口.我需要实现一个后退按钮,并可能需要在PDF上进行一些覆盖.有谁知道在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?

推荐答案

如果您对chrome PDF扩展名提供的UI没问题,则可以从电子上使用它.

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')
})

请注意,电子的本机PDF支持仅从版本1.6.4起可用.在此之前,您可以使用electron-pdf-window

Note, that electron's native PDF support is available only since version 1.6.4. Before that you can use electron-pdf-window

这篇关于在电子中打开pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆