forked from squalle0nhart/electron-pdf-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (33 loc) · 963 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const electron = require('electron');
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
module.exports = {
showpdf, getPdfHtmlURL
};
function showpdf(pdfurl, options) {
"use strict";
if (options === undefined || options === null) {
//using default options
options = {
width: 800, height: 600,
webPreferences: {
nodeIntegration: false
},
title: 'PDF Viewer'
}
}
var win = new BrowserWindow(options);
win.setMenu(null);
var PDF_URL = 'file://' + path.join(__dirname, 'pdfjs', 'web', 'viewer.html?file=');
win.loadURL(PDF_URL + pdfurl);
win.on('closed', function () {
win = null;
});
win.on('ready-to-show', function () {
win = null;
});
return win;
}
function getPdfHtmlURL(pdfurl) {
return 'file://' + path.join(__dirname, 'pdfjs', 'web', 'viewer.html?file=') + pdfurl;
}