Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win.print() "copies" option no longer works. #6440

Closed
ghost opened this issue Feb 1, 2018 · 11 comments
Closed

win.print() "copies" option no longer works. #6440

ghost opened this issue Feb 1, 2018 · 11 comments

Comments

@ghost
Copy link

ghost commented Feb 1, 2018

Hi @rogerwang :-)

NWJS Version : 0.28.0
Operating System : Windows 8.1

Expected behavior

When settings the options object to something like {copies: 5} the printed document should contain 5 copies.

Actual behavior

Only 1 copy gets printed.

How to reproduce

Run win.print() on any open window or open PDF window.

Thanks for your help!

@Christywl
Copy link
Contributor

I can reproduce this issue on Linux/Windows with nwjs-sdk-v0.28.0.

<html>
<p>Hello</p>
<script>
var win = nw.Window.get();
win.print({
 "printer": "Foxit Reader PDF Printer",
 "copies": 5
});
</script>
</html>

@rogerwang
Copy link
Member

Does it work in previous versions?

Just checked with Chromium browser, copies is a capability of the printer (not all printer have it), rather than a print job property, so it should not be supported by the win.print API.

@ghost
Copy link
Author

ghost commented Feb 8, 2018

Dear @rogerwang, thank you for taking the time to address this issue, it used to work in previous builds before Chromium team refactored the printing code. If you remember we've submitted a pull request in the past to integrate it, we even submitted a documentation pull request that you approved :-) and the "copies" option is still in the official nw.js documentation.

In my opinion since Chromium's UI allows the user to specify the number of copies, it should be easy to allow this feature for the win.print API. It's already implemented in the Chromium printing API code.

Thanks!

@rogerwang
Copy link
Member

rogerwang commented Feb 8, 2018 via email

@ghost
Copy link
Author

ghost commented Feb 8, 2018

@rogerwang Yes absolutely, however it's still a useful option to have :-) And it's available in lots of printers under Windows. We're building some automated printing APIs on top of nw.js and this is quite an important little tool, perhaps the Chromium API already handles this? as in even if copies is > 1 and the target printer doesn't support it, it only prints 1 copy.

Can you think of a solution or alternative? I was thinking of trying to submit a pull request last time, but I am not sure if we can do it on the nw.js side only without touching Chromium, since Chromium is constantly changing.

Thanks.

@rogerwang
Copy link
Member

I think it won't work when the printer doesn't support this option. Will it work for you if you put win.print() in a loop?

@ghost
Copy link
Author

ghost commented Feb 8, 2018

@rogerwang Do you mean that it will crash? It's not a big deal if it doesn't print multiple copies for printers that don't support that feature, as long as it doesn't crash or something. The important thing is it will work for the printers that do support the feature, which are plenty.

Unfortunately looping is not very graceful, it doesn't always work since it's a UI operation.

Thanks.

@rogerwang
Copy link
Member

It shouldn't crash, but makes the API unreliable. Will look to fix this.

@ghost
Copy link
Author

ghost commented Feb 22, 2018

Thank you very much @rogerwang. You are awesome.

@ghost
Copy link
Author

ghost commented Jun 21, 2018

Dear @rogerwang Any update concerning this?

Thanks!

@rogerwang rogerwang added the WIP label Jun 22, 2018
@rogerwang
Copy link
Member

This is fixed in git and will be available in the next nightly build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants