views:

437

answers:

3

I have a web based order dispatch system. At the moment, users of the system print out a dispatch note manually (ie, they choose "Print" in their web browser).

I would like to update the system so all the printing is handled by a single dedicated machine. I am expecting it to poll the server to see if anyone needs something printing, then do something to print it. I'm not too sure what that something needs to be.

eg. I can have a page that checks for new print jobs and refreshes itself and uses the javascript print() function, but that obviously still needs someone to press ok. Is there a way to change this behavior. It only has to work on a single PC that I can set up with any options and plugins needed.

Can any of you bright sparks think of a solution that will allow me to get closer to doing what I want to do. eg. Is there a fancy pdf tool that can suck data off the web, fill in a document and print it?

A: 
Byron Whitlock
A: 

If you build a dedicated API (eg webservice) you could then build a windows service to get the data for the despatch notes, create PDF's and send these to a printer.

Added:

The Windows Service will call the WebService and create the PDF files on the local/dedicated printing machine. Ideally the PDF's are created using a reporting tool such as ActiveReports or other reporting tool that generates PDFs (this would make building the reports quicker and editable in future) You could then use GhostScript (open source PDF interpretter) to send the PDFs directly to a named printer.

Mark Redman
...assuming you're looking for advice on what to build...
Mark Redman
I am...............
rikh
+1  A: 

If all I needed to do was print from a Linux server, I would write a very simple web service that accepts pdf through a POST request (from the main web application, not from the user's desktop), saves it to a temporary file, and pipes it into lpr which can accept pdf directly. The standard Linux printing system can easily be configured to print to a Windows or Linux print server or a networked printer instead of a directly attached printer.

To actually generate the .pdf, if you are using fillable pdf forms you can fill in the fields with iText and save the result even if you wouldn't be allowed to in Acrobat Reader. Or you could use iText to generate the whole .pdf from scratch. I've enjoyed using reportlab for pdf generation in Python.

If for some reason you like XSLT then you could use XSL-FO but I think it's painful. http://html2fo.sourceforge.net/ converts html to XSL-FO which can be rendered to pdf and printed.

What exactly are you printing? Do you already have pdf, or do you need to convert web pages to pdf? If you need to render web pages beautifully as pdf then http://www.princexml.com/ is a commercial solution.

joeforker