feat: add a series of new printing options (#18984)

This commit is contained in:
Shelley Vohr 2019-06-29 22:12:00 -07:00 committed by GitHub
parent 684d1838f9
commit 0348b60a34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 187 additions and 7 deletions

View file

@ -1227,9 +1227,26 @@ Returns [`PrinterInfo[]`](structures/printer-info.md).
* `options` Object (optional)
* `silent` Boolean (optional) - Don't ask user for print settings. Default is `false`.
* `printBackground` Boolean (optional) - Also prints the background color and image of
* `printBackground` Boolean (optional) - Prints the background color and image of
the web page. Default is `false`.
* `deviceName` String (optional) - Set the printer device name to use. Default is `''`.
* `color` Boolean (optional) - Set whether the printed web page will be in color or grayscale. Default is `true`.
* `margins` Object (optional)
* `marginType` String (optional) - Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen, you will also need to specify `top`, `bottom`, `left`, and `right`.
* `top` Number (optional) - The top margin of the printed web page, in pixels.
* `bottom` Number (optional) - The bottom margin of the printed web page, in pixels.
* `left` Number (optional) - The left margin of the printed web page, in pixels.
* `right` Number (optional) - The right margin of the printed web page, in pixels.
* `landscape` Boolean (optional) - Whether the web page should be printed in landscape mode. Default is `false`.
* `scaleFactor` Number (optional) - The scale factor of the web page.
* `pagesPerSheet` Number (optional) - The number of pages to print per page sheet.
* `collate` Boolean (optional) - Whether the web page should be collated.
* `copies` Number (optional) - The number of copies of the web page to print.
* `pageRanges` Record<string, number> (optional) - The page range to print. Should have two keys: `from` and `to`.
* `duplexMode` String (optional) - Set the duplex mode of the printed web page. Can be `simplex`, `shortEdge`, or `longEdge`.
* `dpi` Object (optional)
* `horizontal` Number (optional) - The horizontal dpi.
* `vertical` Number (optional) - The vertical dpi.
* `callback` Function (optional)
* `success` Boolean - Indicates success of the print call.
@ -1240,7 +1257,7 @@ for printing.
Calling `window.print()` in web page is equivalent to calling
`webContents.print({ silent: false, printBackground: false, deviceName: '' })`.
Use `page-break-before: always; ` CSS style to force to print to a new page.
Use `page-break-before: always;` CSS style to force to print to a new page.
#### `contents.printToPDF(options)`