View pdf in new browser windows.
English | 简体中文
Use npm or yarn:
# Use npm
npm install electron-pdf-window-s -D
# Use yarn
yarn add electron-pdf-window-s -D
A simple example:
const { app } = require('electron')
// Use defualt export so you could get intelligent completion
const PDFWindow = require('electron-pdf-window-s').default
app.on('ready', () => {
const win = new PDFWindow({
width: 800,
height: 600
})
win.loadURL('http://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf')
})
You will see pdf window is show.
Create a pdf window instance. The option is same as BrowserWindow's option.
Then, you could use loadURL()
to load a PDF file or url.
Static property, specifies path for the pdfjs viewer.
Default is path.join(__dirname, '../viewer/web/viewer.html')
Static method, enable normal BrowserWindow to support loading pdf by loadURL()
.
Special thanks to @gerhardberger. This project is based on his electron-pdf-window. But unfortunately, that library no longer seems to be maintained. So I froked it and created new one.
- Version of pdfjs viewer
- No listeners of
will-navigate
andnew-window
events anymore. - Typescript support
At least >=31.0.0
version.
Website: http://mozilla.github.io/pdf.js/
Version: Stable(v5.1.91)
Options wiki: Viewer options · mozilla/pdf.js Wiki
Changes in this library:
- Remove exmpale pdf file.
- Remove cross origin limit(Delete
validateFileURL()
function inviewer.js
).
Now is unknown
We have modify some code to support signature feature. But we didn't do that in the latest version.