0.1.0-alpha.1 • Published 4 years ago

electron-print-dialog v0.1.0-alpha.1

Weekly downloads
6
License
MIT
Repository
-
Last release
4 years ago

electron-print-dialog

A library to add a print dialog to your Electron app

Install

$ npm install --save electron-print-dialog

Usage

const printDialog = require('electron-print-dialog');
let window;

app.on('ready', function() {
  // Create the parent window
  window = new BrowserWindow({});

  // Attach print listeners to the window
  printDialog.attach(window);
});

// manually open the print dialog
// useful if you have a api request that returns a link to a document and you would like to print it.
printDialog.open(window, {
  data:
    'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
});

API

printDialog.attach(window) *Not Implemented

Add print listeners to the given BrowserWindow to override the default print behavior.

printDialog.open(window, options)

Open the print dialog for the given window and print listeners to the given BrowserWindow.

  • window BrowserWindow (required)- The window to use as the parent window for the print dialog.

  • options Object (optional)

    • data (Uint8Array | String)(optional) - PDF data or a url to print. Supports urls to html, pdf, or png. If not provided the windows webContents will be used instead.