Browse Source

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.
Charles Kerr 4 years ago
parent
commit
00fc8066de
2 changed files with 12 additions and 5 deletions
  1. 10 3
      docs/api/web-contents.md
  2. 2 2
      docs/api/webview-tag.md

+ 10 - 3
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<string, number> (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.

+ 2 - 2
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<string, number> (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<string, number> (optional)
     * `horizontal` Number (optional) - The horizontal dpi.