feat: improve callback value for webContents.print() (#19000)
Resolves #18980. Adds granularity to the optional callback in webContents.print() by adding a failureType value in addition to the success boolean that differentiates between cancelled and failed print jobs.
This commit is contained in:
parent
5154b95447
commit
21d04ed3f4
2 changed files with 41 additions and 20 deletions
|
@ -1249,6 +1249,7 @@ Returns [`PrinterInfo[]`](structures/printer-info.md).
|
|||
* `vertical` Number (optional) - The vertical dpi.
|
||||
* `callback` Function (optional)
|
||||
* `success` Boolean - Indicates success of the print call.
|
||||
* `failureReason` String - Called back if the print fails; can be `cancelled` or `failed`.
|
||||
|
||||
Prints window's web page. When `silent` is set to `true`, Electron will pick
|
||||
the system's default printer if `deviceName` is empty and the default settings
|
||||
|
@ -1259,6 +1260,15 @@ Calling `window.print()` in web page is equivalent to calling
|
|||
|
||||
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' }
|
||||
win.webContents.print(options, (success, errorType) => {
|
||||
if (!success) console.log(errorType)
|
||||
})
|
||||
```
|
||||
|
||||
#### `contents.printToPDF(options)`
|
||||
|
||||
* `options` Object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue