I have sort of an information and booking system with web interface. It is running on 11.3 with apache2, mysql and consists of a couple of plain HTML pages with forms and some CGI scripts written in bash. The CGI scripts produce some letters which are typeset with TeX producing DVI files (can easily be converted to postscript or PDF). That’s all on host A.
Now let’s say a user connects to host A with a browser from host B. He completes a form and clicks a button “Send/Print”. How can I make it that the postscript produced on A is directly printed on a printer attached to host B?
I have a vague feeling that this can be done with javascript, but I know absolutely nothing of javascript. Any hints please?
It still requires the user’s ok on the print dialog.
I noticed you are sending back PS, and maybe don’t want to print the web page. In that case you can send back a Content-type of application/postscript and the user will be asked what to do with it. Usually you can set a default for all content of a given type.
Thank you for the suggestion. To me it seems that window.print() does not solve my problem because I do not print the web page but a generated file (to be correct: several of them). And for the user it is a lot of clicking to accept 30 documents (that is a typical value).
This works with PDF files and lets the user preview what shall be printed. I could try to concatenate many documents into one big PDF with many pages.
This method gives the user some control over the media format and printer tray to use. But I would prefer to print directly if this is possible in any way.
It would be poor security if the web browser did not ask the user before initiating the print operation. I wouldn’t want spammers triggering a print using JS whenever I loaded a window for example. So you still have to ask the user to click on OK.
vodoo wrote:
> I have sort of an information and booking system with web interface. It
> is running on 11.3 with apache2, mysql and consists of a couple of plain
> HTML pages with forms and some CGI scripts written in bash. The CGI
> scripts produce some letters which are typeset with TeX producing DVI
> files (can easily be converted to postscript or PDF). That’s all on host
> A.
>
> Now let’s say a user connects to host A with a browser from host B. He
> completes a form and clicks a button “Send/Print”. How can I make it
> that the postscript produced on A is directly printed on a printer
> attached to host B?
>
> I have a vague feeling that this can be done with javascript, but I
> know absolutely nothing of javascript. Any hints please?
Using Javascript for this is a bad idea. Javascript introduces security
risks for the client and unless done carefully can cause accessibility
problems.
What you should do, IMHO, is make your Send/Print button redirect the
user to another page/URL that contains the printed content. I would
suggest using PDF rather than PS as it is more commonly used. So the
user is redirected by the Print button from http://your.domain.com/your-page-NNN.html to http://your.domain.com/your-page-NNN.pdf and when your server is asked
to serve the PDF page, it simply does that, like any other request.
The user can then just print the page. That leaves them in full control.