docs: clarify use of pageRanges when printing. (#24694)

Fixes #24684 -- the docs are slightly unclear about how pageRanges
should be used, e.g. whether the page indices are zero-based or
one-based.
This commit is contained in:
Charles Kerr 2020-07-23 14:03:52 -05:00 committed by GitHub
parent 6b1de271a7
commit 00fc8066de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -1321,7 +1321,14 @@ Use `page-break-before: always;` CSS style to force to print to a new page.
Example usage: Example usage:
```js ```js
const options = { silent: true, deviceName: 'My-Printer' } const options = {
silent: true,
deviceName: 'My-Printer',
pageRanges: {
from: 0,
to: 1
}
}
win.webContents.print(options, (success, errorType) => { win.webContents.print(options, (success, errorType) => {
if (!success) console.log(errorType) if (!success) console.log(errorType)
}) })
@ -1338,8 +1345,8 @@ win.webContents.print(options, (success, errorType) => {
default margin, 1 for no margin, and 2 for minimum margin. default margin, 1 for no margin, and 2 for minimum margin.
* `scaleFactor` Number (optional) - The scale factor of the web page. Can range from 0 to 100. * `scaleFactor` Number (optional) - The scale factor of the web page. Can range from 0 to 100.
* `pageRanges` Record<string, number> (optional) - The page range to print. * `pageRanges` Record<string, number> (optional) - The page range to print.
* `from` Number - the first page to print. * `from` Number - zero-based index of the first page to print.
* `to` Number - the last page to print (inclusive). * `to` Number - zero-based index of the last page to print (inclusive).
* `pageSize` String | Size (optional) - Specify page size of the generated PDF. Can be `A3`, * `pageSize` String | Size (optional) - Specify page size of the generated PDF. Can be `A3`,
`A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` and `width` in microns. `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` and `width` in microns.
* `printBackground` Boolean (optional) - Whether to print CSS backgrounds. * `printBackground` Boolean (optional) - Whether to print CSS backgrounds.

View file

@ -561,8 +561,8 @@ Stops any `findInPage` request for the `webview` with the provided `action`.
* `collate` Boolean (optional) - Whether the web page should be collated. * `collate` Boolean (optional) - Whether the web page should be collated.
* `copies` Number (optional) - The number of copies of the web page to print. * `copies` Number (optional) - The number of copies of the web page to print.
* `pageRanges` Record<string, number> (optional) - The page range to print. * `pageRanges` Record<string, number> (optional) - The page range to print.
* `from` Number - the start page. * `from` Number - zero-based index of the first page to print.
* `to` Number - the end page. * `to` Number - zero-based index of the last page to print (inclusive).
* `duplexMode` String (optional) - Set the duplex mode of the printed web page. Can be `simplex`, `shortEdge`, or `longEdge`. * `duplexMode` String (optional) - Set the duplex mode of the printed web page. Can be `simplex`, `shortEdge`, or `longEdge`.
* `dpi` Record<string, number> (optional) * `dpi` Record<string, number> (optional)
* `horizontal` Number (optional) - The horizontal dpi. * `horizontal` Number (optional) - The horizontal dpi.