From 00fc8066de5c6617769567ec0369f10a271426f8 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 23 Jul 2020 14:03:52 -0500 Subject: [PATCH] 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. --- docs/api/web-contents.md | 13 ++++++++++--- docs/api/webview-tag.md | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 9ecca61b53da..0aa5609c9344 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1321,7 +1321,14 @@ Use `page-break-before: always;` CSS style to force to print to a new page. Example usage: ```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) => { 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. * `scaleFactor` Number (optional) - The scale factor of the web page. Can range from 0 to 100. * `pageRanges` Record (optional) - The page range to print. - * `from` Number - the first page to print. - * `to` Number - the last page to print (inclusive). + * `from` Number - zero-based index of the first page to print. + * `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`, `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` and `width` in microns. * `printBackground` Boolean (optional) - Whether to print CSS backgrounds. diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index 7ce64bf3dfba..65d3c2284d7f 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -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. * `copies` Number (optional) - The number of copies of the web page to print. * `pageRanges` Record (optional) - The page range to print. - * `from` Number - the start page. - * `to` Number - the end page. + * `from` Number - zero-based index of the first page to print. + * `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`. * `dpi` Record (optional) * `horizontal` Number (optional) - The horizontal dpi.