I want to send a html text request to printer using PHP.
What I did was
window.print()
in JS, which is showing me a print dialog box, which is something I don't need. I
have used browser config:
firefox always_print_silent
I want to send the print command without changing the config on the client. I need a solution for any popup or dialog box and one that will work on any browser.
If anyone has a solution for this please reply.
If a web page could just send something to the printer without the user confirming it in some way, we'd have a wave of nasty spam and jokers that would print NSFW pictures until you run out of paper. I think we all agree that would be bad. So no, you cannot have a web page print without the browser showing a dialog box… unless the user knows what (s)he is doing and is explicitly disabling that like with the always_print_silent option.
Related
I´m making a simple webapp, I want that when it is open in mobile phones print some data using the user´s wifi printer which most of cases will be an Epson L355.
Can anybody give me a clue or sample to achieve this?
Thank you all.
You won't be able to do this because you don't have access to the user's printer. Instead, you can just generate a pdf and redirect user on it.
The user will then be able to download / print the pdf via his inline PDF viewer.
You can do it by following this :
How to force files to open in browser instead of download (pdf)?
i'm developing a Ruby on Rails application and i trying to print a PDF in silent mode, in the words, after user press print dialog confirmation, the application get the default printer and send it.
One of my options, is create a Google Chrome extension, that user can manage the printer and size of paper and etc, only once. And all time that user want to print a PDF the extension send it silently to the default printer.
So, how can i do this extension?
There's any way to manage user print config with js?
There are a better way to do that?
Thanks.
How to print printer model on a PDF file when I print the file?
Anyone know the correct Javascript to obtain this result?
I don't think you can do this. Once the user has a PDF open on your site, it's a bit out of your hands: they have the PDF, and when they go to print it, the dialog box to choose a printer is provided by the system--not by your site, and maybe not even by the browser, really. I don't see how you can influence the content of the about-to-be-printed PDF between the time that the user chose to print it and the time that it actually is committed to paper.
I am developing a web-based POS. Unfortunately, POS must print through a thermal receipt printer (TM-T88IV, Epson). The web application is based on Django. Is there any idea on how the system could automatically print a receipt whenever a user clicks a control in the web application?
I was thinking of creating other services in python for that purpose, but that would defeat the purpose of having a web application, where all you need is a browser, without any extra installation.
The printer is connected to the client by the way, and the printing should be "silently" triggered, which means that there is no need for human intervention. Once the transaction is finalized, the printing should starts.
Any suggestion is welcomed!
I see two ways to accomplish it:
First method - Configure your browser
Notes
Good solution if you have one printer for every client (because you can use the default printer only). Keep in mind that you can remove your print server (useful for very resource limited devices) making a script that the browser should automatically execute for open your file. You can use something like this:
#!/bin/bash
printer="/dev/usb/lp0"
encoding_needed=true #false
if $encoding_needed; then
iconv -c -t 437 $1 > $printer
else
cat $1 > $printer
fi
Firefox
Manual setup:
Open about:config
Create a new boolean value called print.always_print_silent and set it to True
Create a new boolean value called print.show_print_progress and set it to False
Use an extension, like: https://addons.mozilla.org/en-us/firefox/addon/attendprint/
Keep in mind that there are other extensions for making kiosks, for example:
https://addons.mozilla.org/en-us/firefox/addon/r-kiosk/
https://addons.mozilla.org/en-us/firefox/addon/mkiosk/
Chrome
You can start it with those options: --kiosk --kiosk-printing
Internet Explorer
For kiosk mode see: http://support.microsoft.com/kb/154780
Second method - Server handles every printer
Notes
Good solution if:
You have more clients than printers (few money or faulty printers)
More printers than clients (different printers or paper colors for different needs)
Clients that can't print directly (PDA/smartphones)
You want to know the printer status
How to do
Connect printers (to the clients and/or to the server)
Share printers connected to clients over the network
Manage every printer from your Django server
Two options here: print an html page or provide a PDF file.
Note: it was not clear initially that prints should be automatic, which means the answer is not directly useful to OP.
HTML + "Print Me"
Show the receipt as an html page, then create a media="print" CSS stylesheet which the browser will use when printing the receipt. There's a lot to say about CSS print style sheets, but what's important is that you should remove all navigation elements and images that are going to be expensive to print.
When you do this, the user will simply have to print the page himself. You can also add a "Print Me" button which is going to show your user a printer dialog. This is done via JavaScript:
Print this page
(This is a bit obstrusive for your clients who don't have JS, check this tutorial about JS printing for a better way.)
PDF
Generate a PDF in Django, and show it to the user. He will be free to print it or save it on his computer later. Most web sites do this since it's far easier to control the layout of a PDF file, and it will be easier to make it look like a real receipt.
XSL-FO can help you do this (it translates an XML to a PDF with a "stylesheet").
A more Pythonic way seems to be explained in the Django docs
The above pages lists alternatives such as xhtml2pdf (Pisa) which seems to be used a lot on StackOverflow
If using raw/esc/p try jzebra on google code.
I need to set up a print button in HTML that will print a certain PDF file, hopefully without having to download the file first. I've tried a few things but some only work in IE. and some require downloading the file as an embedded object which also is not acceptable. Embedding javascript in the PDF sounds the most promising, but I'd rather avoid that if possible for other reasons.
Any other ideas?
Unfortunately it really can't be done... PDFs are not handled naively by any browser, and as is such they can't be printed using the browser's print dialog.
Your users will have to download the pdf and print it with whatever PDF software they use (Even if it's just a plugin for the browser) unless you convert it to boring old html or an image or something.
You cannot print something without the user downloading it first.
The printer is located on the user end of the connection. The PDF is, at first, located on the server end.
The PDF must thus travel across the webs to reach the user end before the printer will know which ink to put on paper. In other words, it must be downloaded.
I think the best you can do is download the PDF into an iframe element, and advise the user to click the "print" button in there. To my knowledge, no tighter integration than that is possible. The PDF viewer's print button can not be accessed via JavaScript.