This is going to sound like an odd request, but... I have a web application that is set up to collect data and store it into a database on regular intervals. The application
There is a similar Question at How do I create a web based print server?
We optet for creating a native print client. See http://mdornseif.github.com/2011/01/08/PDF-on-appengine.html for details.
The print functionality is handled by the browser (and is thus unique per browser), it can be called (by javascript), but cannot be forced to print
(here's the javascript to call the print method in the browser)
<script language="Javascript1.2">
<!--
function printpage() {
window.print();
}
//-->
</script>
You could write a separate application that has a web-browser control, and have it do the printing for you. There's no way to do it in a regular browser, though --- think of the implications of that.
you can bring up the print dialog using JS, i think its window.print(), which you could put with your ajax call. regarding the auto click i am not sure.
As others have pointed out – isn't really possible to complete the print task in a web browser dialog window without human intervention or macros to control the mouse.
Instead of having the browser do the printing, I would suggest you have your ajax requests trigger something that saves the data to be printed into a file (wkhtmltopdf is one option) and have your web server (which could be Linux, OSX, Windows Server) monitor a folder and print (and then delete) whatever appears in that folder. In OSX you could do this quite easily with Automator. In Linux you could write a bash script that monitors the folder every X minutes (via cron) and runs the lpr
program to send files to the printer. On Windows... well, I have no idea what you'd do, but I do recall seeing something like a folder-as-print-queue option in older versions of Windows in the printer's properties. I could be making that up, though.