Is it possible to print from a website directly to the printer ?
maybe if i first write the file than save it to a local folder, and after saving it would be run the printer? like printer spooling?
I printing now with web dialog ... ut would like to send it direct to the local printer.
As far as I understand you want a solution for server-side printing, right?
If it is a network-enabled printer that's connected to the server that serves the web page, you could use the lp Linux command. On Windows you can use the lpr command.
The file to print could be generated from the web page code with wkhtmltopdf or mpdf.
If it's not on the same network, you could set up a script on the printer network that checks an email address and sends the attachments from specific emails to the printer.
js print function should do, but you will get the dialogue to confirm printing, this is a security measure on the browser to prevent hackers from using your printer.
You can overcome this dialogue in the browser setting.
Related
I have been tasked with figuring out how to get our zebra label printers(mostly the 420t models) to print over the network from calls in one of our PHP applications. I've come up with a couple of ideas but wanted to run it past people more knowledgeable than I am before I start down one path or the other.
Setup a machine to be a print server which has the zebra on USB as the default printer. I'd have to write some sort of print queue script or something to run on this machine.
Get a zebra printer with a network port and directly send print requests to it. I have seen a couple of other SO questions about it and it seems to require sending in the RAW over sockets. From the answers on these questions it seemed like there were some issues with doing this.
Send the print request via FTP somehow as mentioned in a few places.
Use either 1 or 2 with the LPR library.
What do you guys suggest?
I use intersively the second solution at work, ie using network enabled printers, and sending them (via cURL to the printers IP) data from a .prn file with my replacements.
The models we use are G4K20d.
I would like to use a receipt printer with my web based POS.. Before i go any further i know you can not force print a receipt from the browser and the only options are to do it via PHP, and cups, which is not an option or a Java Applet, Prefer no to..
My question is im looking at the Star Micronics TSP-100 and would like to send a PDF to it. I have looked all over and can not find if receipt printers will print standard PDF's..
Also if anyone has any experience with this any tips would be helpful.. Ie what page size do you set?
EDIT: The server platform is Linux, PHP / MYSQL and im using Yii with the epdf plugin. PDF generation is not the issue. It unclear if a receipt printer can print a pdf. Also what page properties should i use when setting up the document. Ie width / height.. Width i know is determined by the printer, but im curious to height.
You cannot force a receipt print from the browser but you can use an Active X control (in IE) and print the receipt locally.
What I did was:
1. generate the pdf on the server
2. call an Active X command to download the PDF using wget (this puts the file on the local machine.
objShell.run('cmd /K wget -P /pos/invoices/ http://url.com/pos/<?php echo $filename;?>',0,false);
call an Active x command to print the local PDF using Adobe command line
objShell.run('"C:\\Program Files (x86)\\Adobe\\Reader 11.0\\Reader\\AcroRd32.exe" /h /s /o /t "C:\\pos\\<?php echo $filename;?>"');
In order to print to your receipt printer, you just need to set it as default printer or change the Active x commands to include the printer name. I am still working on the paper size issue.
I realize you are using Linux so the Windows commands will not work but the process is the same.
Your question is not too clear. You did not mention which operating system are you using.
I think, you have two problems
Printing a PDF from PHP. I found this Adobe Reader Command Line Reference
Generating a PDF from a template. I can recommend wkhtmltopdf, which is exists for MS-Windows and Linux platforms. It uses WebKit to render page, so the source is plain HTML+CSS.
I have a program in a remote server. The users of this program generate a lot of receipt PDF files.
The users of this service need to print these generated PDF's automatically with their local printers. Doing this this manually is too expensive and takes too much time. Is there a way to automatically print the downloaded PDFs?
Automatic print email, works fine.
http://www.automatic-print-email.com/
With this program you can setup your mail account and print message attachments in PDF.
You can configure the frequency mail refresh on seconds, and choose the printer.
Depends on the network architecture you use, but you could think of calling a shell command from php to have the server OS print the files. Additionally, if the user printers are available to the server, you could specify the printer the document has to go to with something like lpr [-Pprinter]...
Of course this requires you to have full control of the server...
I am creating an application in PHP and want to give a command to a printer but problem is that there are more than two printers and I want to give the command to a different printer by clicking on different button without the print dialog.
you can use:
printer_list()
function to get list of printers attached to server, and then use:
printer_open
to open connection to printer providing printer name as parameter to the function.
I hope that helps you to some extent
In online web applications you can't.
A workaround could be to write Java Applet or in IE you can do this via ActiveX controls.
I am working on a project that will end up printing receipts, my client uses a dot-matrix printer (some old version). He will need a system where receipt printing will be fast i.e. time efficient, and not opening a dialog box and choosing a printer...moreover the printer will be shared through a network.
The main problem is that all this should be done using PHP. the following are some thoughts of solutions.
Design a php script to write data to a text file then print the text file using a remote printer
-the problem is that I am having a hard time getting server side printing from PHP. Logically it seems to work.
Platform =====> WIN XP
Printer Location =====> Main server on a LAN N/W
What's the intended workflow before the user hit's enter?
What's the make and model of printer? This is important so that we can see if it needs any fancy escape codes sent to it?
Usually if you're printing then it would be sent from the client machine.
If printing from the server the data needs to be either sent to the server or needs to already be there and accessible. Is it already there in a database? Or are you sending a webform?
You say RCPT, is this a receipt?
Okay, so if you have the text file created on the server you should be able to copy the text file to lpt1: or 2: or whatever device it's defined as.
You need to know what the file's named as, or you could pass it on, but how about:
exec('c:\WINDOWS\system32\cmd.exe /c START C:\some_dir\print_me.bat');