Reputation: 113
I'm trying to open pdf in electron app with electron-pdf-window. Its working fine before build but when i build app as installer .exe file for windows and install exe file on windows 8.1 , its not showing pdf window, i am using it through renderer process on click of anchor. Any ideas? here is my code
function pdfWindow() {
const { BrowserWindow } = require('electron').remote
const PDFWindow = require('electron-pdf-window')
const win = new BrowserWindow({ width: 800, height: 800 })
PDFWindow.addSupport(win)
win.loadURL('http://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf')
}
and i am calling this function on click of anchor tag
Upvotes: 0
Views: 1611
Reputation: 8176
If you're using the latest Electron 1.8 or newer, it has built in PDF support in BrowserWindow
's and <webview>
tags. You just have to ensure plugins are enabled:
BrowserWindow
const window = new BrowserWindow({
width: 1024,
height: 800,
webPreferences: {
plugins: true
}
});
window.loadURL('path/to/file.pdf');
<webview>
Tag<webview src="path/to/file.pdf" plugins></webview>
Upvotes: 1