GithubHelp home page GithubHelp logo

hhy5277 / electron-pdf-window Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gerhardberger/electron-pdf-window

0.0 1.0 0.0 2.35 MB

view PDF files in electron browser windows

License: MIT License

JavaScript 92.50% CSS 5.42% HTML 2.08%

electron-pdf-window's Introduction

electron-pdf-window

view PDF files in electron browser windows. this module adds support for viewing PDF files in electron BrowserWindows. it works even if you navigate to a PDF file from a site, or opening a PDF file in a new window. a PDFWindow instance is just a subclass of BrowserWindow so it can be used just like it.

const { app } = require('electron')
const PDFWindow = require('electron-pdf-window')

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

install

$ npm i electron-pdf-window

usage

win = new PDFWindow([opts])

win is an electron BrowserWindow that has support for viewing PDF files.

PDFWindow.addSupport(win)

adds PDF viewing support for win, which is a BrowserWindow instance.

using from the renderer process

Using the PDFWindow class directly from the renderer process is not recommended, because electron doesn't support proper extending of their built-in classes. In order to add PDF support from the renderer, use the addSupport method.

const { BrowserWindow } = require('electron').remote
const PDFWindow = require('electron-pdf-window')

const win = new BrowserWindow({ width: 800, height: 600 })

PDFWindow.addSupport(win)

win.loadURL('file:///a/b/c.pdf')

test

$ npm test

electron-pdf-window's People

Contributors

gerhardberger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.