views:

115

answers:

2

Is it possible for my python web app to provide an option the for user to automatically send jobs to the locally connected printer? Or will the user always have to use the browser to manually print out everything.

A: 

If your Python webapp is running inside a browser on the client machine, I don't see any other way than manually for the user.

Some workarounds you might want to investigate:

  • if you web app is installed on the client machine, you will be able to connect directly to the printer, as you have access to the underlying OS system.
  • you could potentially create a plugin that can be installed on the browser that does this for him, but I have no clue as how this works technically.
  • what is it that you want to print ? You could generate a pdf that contains everything that the user needs to print, in one go ?
Alex Boschmans
I dont really understand how to install a web app? HTML 5? Is there a specific tutorial or example you can refer me to?
Ali
What I meant was using your webapp as a local app, installing it on the users machine. Sort of defeats the purpose of a remote web application, but I have used it for some applications where it was just easier to do so and I just needed a minimalistic interface.
Alex Boschmans
Is there a good tutorial on having a local app that continuously receives input from the web and print out automatically to a printer?
Ali
A: 

You can serve to the user's browser a webpage that includes the necessary Javascript code to perform the printing if the user clicks to request it, as shown for example here (a pretty dated article, but the key idea of using Javascript to call window.print has not changed, and the article has some useful suggestions, e.g. on making a printer-friendly page; you can locate lots of other articles mentioning window.print with a web search, if you wish).

Calling window.print (from the Javascript part of the page that your Python server-side code will serve) will actually (in all browsers/OSs I know) bring up a print dialog, so the user gets system-appropriate options (picking a printer if he has several, maybe saving as PDF instead of doing an actual print if his system supports that, etc, etc).

Alex Martelli
My web app requires a continuous stream of automatic printing i.e it prints even if the user is not actively looking at it. Can the user authorize the script once and then just have it print automatically?
Ali
@Ali, I believe most browsers will not allow that kind of interaction without extensions/plugins. Could you write such plug-ins or extensions for all kinds of browsers your users may want to use (unfortunately there's no standard for those so it will have to be done over and over again -- and the only way to do it in Python would probably be with MS Silverlight add-in for IE and Safari)...?
Alex Martelli
Can a firefox or Chrome extension achieve the printing?
Ali
@Ali, I suspect it can, but that's a better subject for one or two separate question since the issue has absolutely nothing to do with Python and everything to do with Firefox and Chrome extensions, thus needing completely different tags. Big questions in comment threads (esp. threads on questions with totally unrelated tags) are a terrible idea -- as should be obvious, the people who might best answer your new question may know 0 about Python (which is completely unrelated to that question) and thus be skipping this thread entirely!
Alex Martelli