• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to automate printing from web applications ?

 
Bartender
Posts: 1359
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scenario: I'm developing a web application that will produce a number of PDF, that need to be printed to a phisical device. For the nature of my business process, I can't simply put produced PDFs in a shared folder and let the users browse for them.  The process requires PDFs to be printed to different printers - the choice of the actual printer depends  upon a bunch of parameters - without user's intervention; the whole process must be fulfilled
with no user interaction.  So, I'm searching for a third-party product (better if open, of course) to centralize the printing process. In an ideal scenario, I should be able to submit a PDF to this software via API
(or something similar), and let it handle the printing process.

Could you suggest me a solution to adopt ?
 
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mention "users" several times - would the documents be printed on some user's machine, or somewhere on the server's network? The former is impossible for a web app to achieve without user intervention, while the latter should pose no particular problem.
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the  nastier hacks back long ago was to send an unwanted print job to someone else's printer(s) and consume resources by eating large quantities of paper and making the printer unavailable for legitimate use while it was tied up printing junk.

As a result, web clients are absolutely forbidden to take control of the client machine printers and file systems automatically. You can only do so via a manually-approved dialog.

You can deal with this in one of 2 ways:

1. Write a custom HTTP client application that issues URL requests, spools them, then dumps the downloaded documents to the printer. I *think* the standard Java desktop security sandbox allows this. If not, you'd have to override it.

2. Set up remote print clients. For example, if I wanted satellite data centers with printers to continually receive or print jobs, I could set up a client CUPS server at each satellite location.

CUPS stands for something like Common Unix Print Server and was originally developed by Apple, but is now the standard for many Linux and Unix systems. It's also available for Microsoft Windows, although I think it's messier to set up there as a server - as a client, it's quite simple. CUPS behaves much like the Apache HTTPD web server and much of the configuration options are similar. The main difference is that it uses port 631 ("ipp") instead of port 80/443 and some of the CUPs URLs target print queues and other printing resources.

Although not generally advisable over open Internet, CUPS is very good over LANs and VPNs. It does have infuriatingly tight security mechanisms - I just generally discourage exotic services on the Open Internet because if nothing worse, someone between here and there may firewall them.

If you have major ambitions, I'd recommend CUPs over a custom client app. It's already written, debugged and well-supported and it integrates with your overall printing infrastructure. At my site, CUPs prints from the desktops of both Linux and Windows machines and it supports printing to a variety of devices. And includes the ability to classify and route print jobs to specific printers.
 
Claude Moore
Bartender
Posts: 1359
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you guys for your quick response.  In a nuthsell, what I need to achive is the following:
- an user, via a web interface, chooses to print some generated documents (for example: invoices, customers' orders confirmations, and so on).
- via Jasper (or similar) a PDF is produced by backend layer (essentially a Spring application);
- backend layer looks up for the printer associated with the user that requested the action;
- i need a way to spool the PDF to the printer.

Historically, the workflow we used to use has been:
- the layer responsible to generate the PDF dumps any produced PDF as a Blob on a MySql table;
- a stand-alone application, on client side, reads the BLOB and via Adobe reader prints out the PDFs on the given printers.

The whole thing works, but it smells too much of an handmade solution... using cups seems interesting; is there any wrapper build around it  one can use ?
 
Tim Holloway
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CUPS is itself a print job manager. For Unix/Linux, the legacy "lpr" command will route to CUPS. There is also a Java API that I think would be useful to you: https://github.com/harwey/cups4j

Note that since CUPS is a server technology, it's addressed via URLs, unlike the Windows printing subsystem, where you talk more or less directly to the printer itself. So if you have a satellite office in Newark and it has 3 printers - say one for bulk prints, one for the desktop users on the first floor and one for desktop users on the second floor, you could define 3 printer classes at that host location and thus, for example, send a PDF as a CUPs job to something like this: ipp://printers.newark.mydomain.internal:631/bulkprint/.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic