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...
Related
First of all, sorry for my English, I have been with this problem for quite a few days. I will comment on my situation: I am doing an online ordering system, where once an order is created the ticket printing is triggered. I have tried using Google Cloud Print, it prints but it takes a long time and it does not work as it should, I tried a library called mike42, it prints perfect but not from a website.
The system is in a hosting and I am using PHP together with slim 3, if any of you know how to solve this I would really appreciate it.
The result I want (to be more specific) is the following: The employed user logs on the web (system hosted in the hosting), goes to the orders menu, when he clicks on create the order, this function is executed and prints the ticket directly on the thermal printer connected to the local machine. The same works only if the web is on the local server, which is not what I want.
The title is clear and complete. Printing must take place in client side browser. Client may be connected to a cloud based accounting or purchase system and POS termal printer is connected through a USB port. Computer mat be a zero client with just a browser.
Well, PHP is a server side language, that means it has no communication with the hardware of the local machine.
I've already had to do similar work, and there are two possible solutions:
1- Install PHP on a machine connected to the printer directly, and then print, which is a little impracticable since the server would have to be physically on site.
2 - Generate an output in text formatted for the width of the print and use the window.print () javascript function to call up the print screen, and the user would just click on print.
When I needed it I ended up opting for the second alternative, and it worked well, it is a bit boring to get the print size right, but it worked well.
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.
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.
I'm trying to figure out if there's a way in PHP to open a file on a user's desktop (i.e., the user select a file from a file list shown on a PHP page, and then the file opens with the appropriate program on the user's desktop as if the user had double-clicked it in the GUI.) After searching for a while, I discovered that this is possible via some convoluted-looking code using the COM object in PHP, but that's only going to work for Windows users and I'm trying to keep this platform agnostic.
Has anyone else ever tried to do this and succeeded?
You can't execute an application on the user's machine without either a lengthy "user consent" process, or the user voluntarily (and, ideally, knowingly) installing some software component.
I think the cleanest way might be to use a (signed!) Java applet.
Otherwise you could try and make the user register a specific protocol, with a suitable protocol handler, that you would let download and install on the user's system to intercept a link such as exec://format%20C%2C ;-)
Unfortunately, the file:// protocol is (understandably) restricted. For example, in Firefox it will work (somewhat) if you insert manually "C:\" in the address bar and navigate. If you click on those links they will (somewhat) work. Copy the same links in a document in a different security context (e.g. Internet) and lo and behold, it won't work.
Another possibility would be to backdoor all the intranet clients with, um, REXECd (available on most platforms) or some clone. Then when the user clicks, you send the command from PHP to the user's workstation. Since nowadays PC's are multiuser platforms, you'll need some quick legwork to determine how to do the deed. E.g. on a Linux box you'd have to run a X application with the appropriate ownership and DISPLAY value.
You could also "recognize" the user's platform and let the user download an appropriate batch file, either .sh or .bat or .cmd; but they would need a click to download, one to approve, one to open the executable.
You can't run files on client. It's a big security hole and browser will not allow you do that.
On windows you can use ActiveX, but client must allow installing ActiveX component, and you will have many problems with it.
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');