2

I am building a Google Chrome Packaged App. I have a requirement to access printer available via a "Closed" Network (not connected as USB). Obviously Chrome Cloud Print API is NOT my option, since I'm talking about "Closed" network, hence no internet access (besides I need to print very fast, so even if I had internet I could not afford to go via Cloud and wait few seconds to print.). I have done my research, so far this seems to be NOT possible in Google Chrome Packaged App. Please let me know if I've overlooked something, or if there's a workaround.

Thanks very much.

D.S
  • 1,110
  • 3
  • 11
  • 26
  • Is a Chrome Packaged App a hard-requirement? Are you able to [leverage other technologies](http://stackoverflow.com/a/28783269/3196753) while still keeping the "Closed" network requirement? – tresf Oct 27 '16 at 05:20

2 Answers2

2

If the printer is available in the same network, you can access it using Network Communications with the Sockets API.

xmarcos
  • 3,298
  • 2
  • 20
  • 27
1

If you're OK with requiring user confirmation before printing, then you can use window.print(), which works in Chrome apps with a couple of limitations: 1) There was a bug that could cause crashes on OS X (http://crbug.com/297179), and while this bug is fixed in the Canary and Dev versions of Chrome, it will take a few weeks for the fix to make its way to the Beta and Stable versions; 2) On Window and Linux/Chrome OS, the size of the print preview panel is limited to the size of the window being printed, so you need to make sure that window is large enough to make all of the print preview UI accessible to users.

Because window.print() has not been used very much so far in Chrome apps, you may run into issues with it that have not been seen by others. If you do, please report them at http://crbug.com/new.

If you need the print to happen without user confirmation, your program may have to use the sockets API to communicate directly with your printer or print server (as described by xmarcos in another response to this question). You will probably need to use something like pdf.js (as described at Converting canvas to pdf) to convert what you want to print to something your pinter will understand.

Community
  • 1
  • 1
dharcourt
  • 859
  • 1
  • 8
  • 6
  • Also, for options to print using window.print() but without user intervention, follow [Chromium issue 31395](http://crbug.com/31395). – dharcourt Oct 10 '13 at 20:32