Skip to content

Commit adc7750

Browse files
committed
add print option: autoprint and footerString
Fix nwjs#5702
1 parent e21b92d commit adc7750

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/References/Window.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ See also [`win.showDevTools()`](#winshowdevtoolsiframe-callback).
297297

298298
## win.print(options)
299299

300-
Print the web contents in the window without the need for user's interaction. `options` is a JSON object with the following fields:
300+
Print the web contents in the window with or without the need for user's interaction. `options` is a JSON object with the following fields:
301301

302+
* `autoprint` `{Boolean}` whether to print without the need for user's interaction; optional, true by default
302303
* `printer` `{String}` the device name of the printer returned by `nw.Window.getPrinters()`; No need to set this when printing to PDF
303304
* `pdf_path` `{String}` the path of the output PDF when printing to PDF
304305
* `headerFooterEnabled` `{Boolean}` whether to enable header and footer
@@ -308,6 +309,7 @@ Print the web contents in the window without the need for user's interaction. `o
308309
* `marginsType` `{Integer}` 0 - Default; 1 - No margins; 2 - minimum; 3 - Custom, see `marginsCustom`.
309310
* `marginsCustom` `{JSON Object}` the custom margin setting; units are points.
310311
* `copies` `{Integer}` the number of copies to print.
312+
* `footerString` `{String}` string to replace the URL in the footer.
311313

312314
`marginsCustom` example: `"marginsCustom":{"marginBottom":54,"marginLeft":70,"marginRight":28,"marginTop":32}`
313315
`mediaSize` example: `'mediaSize':{'name': 'CUSTOM', 'width_microns': 279400, 'height_microns': 215900, 'custom_display_name':'Letter', 'is_default': true}`

src/resources/api_nw_window.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ nw_binding.registerCustomHook(function(bindingsAPI) {
504504

505505
NWWindow.prototype.print = function(option) {
506506
var _option = JSON.parse(JSON.stringify(option));
507-
_option["autoprint"] = true;
507+
if (!("autoprint" in _option))
508+
_option["autoprint"] = true;
508509
if (option.pdf_path)
509510
_option["printer"] = "Save as PDF";
510511
currentNWWindowInternal.setPrintSettingsInternal(_option);

0 commit comments

Comments
 (0)