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.
Related
I'm trying to print ZPL Code generated by my web-interface to a Zebra printer(Zebra GK420d)configured as Generic / Text Only printer this works fine in firefox.In Chrome and IE it is not working. I am using latest IE and Chrome versions and my Operating system is windows 8. I cleared my cache and cookies and tried. But i am unable to print. Here is my sample zpl barcode like this.
^XA ^FWR ^FO 425,450^A0,20,30
^FH^FDCHEDDI_20JAGAN_20AIRPORT_20GUYANA_20OWN_20CLEARING^FS
^FO 300,450^AD^BY2 ^BC,100,Y,N,N ^MD1 ^FO 300,450^A0,20,30^FH^FDDATE_3A14-10-2014^FS
^FO 200,450^A0,20,40^FH^FDLTX106970_2D1_281_29_2D_UGAC^FS ^XZ
Please help me how to resolve this problem.Thanks in advance
The answer is, by default, you can't print directly to a Generic/Text-Only printer profile from the Chrome browser. Chrome pre-processes/renders all prints, which takes away the raw text delivery to a printer. It would actually render the characters of the text rather than sending the raw text itself. There used to be an option to enable the Text-only setting in Chrome, but it was removed somewhere around version 22.
There is a project called JZebra/qz (https://code.google.com/p/jzebra/). This will allow you to print to the Zebra printer from the Chrome browser. This requires Javascript added to your site in the printing process code, and requires Java on the client's computer. It will ask to install a little Java program to their computer to intercept and handle the special printing scenarios. If your client doesn't have or want Java or the installed program on their machine, it won't work. You can use the free/unsigned version of the program, but there is a cost if you want a digitally signed version of the consumer-downloaded Java application.
I have a website which runs a box office service which issues tickets and reports. I am trying to figure out how to get tickets (currently PDFs) sent directly to a specified printer on a local/client PC.
I have followed many old/dead/useless links and have not found any up-to-date solutions to this although many tantalising glimmers of hope.
The scenario is this: Remote hosted website - 1 or more users connected - web page generates ticket/s (PDF) which is sent to a specified printer on the user pc (not the default printer) silently (no extra clicking through of print prompts).
I know PHP does not connect to a clients pc but is there a way for a web page (via jQuery perhaps) to connect to an installed script/service?
I was thinking the script on a local PC (which establishes a trusted link, sets the printer to use, etc) would receive data/file from the web server and then process it as long as it was in the same place on every machine. This (local) script then can be added to any PC that needs to run the service. The work would need to be trigged by the file being sent and not having a script/service which is sat polling a location every few seconds.
Any pointers would be greatly appreciated.
Edit: I have tried the jZebra java applet but only got it printing once before it broke. Interested if anyone has actually got it to work (and how).
I ran into the EXACT same question recently myself. Google Chrome has what's called a "kiosk" mode. Therefore, it will print without user intervention.
To do this, open Google Chrome with the following command (you need to find the chrome executable, or chrome command for *nix machines):
chrome.exe "http://www.example.com/mypage.php" --kiosk --kiosk-printing
This will open a window without any toolbars, address bars, omniboxes, etc.
Next, you need to make a page print. To do this, automatically open a print dialog (for demonstration, I'll use simple Javascript):
<script>
window.print();
</script>
Before you jump over to your development environment, window.print() does NOT allow any arguments (i.e. a URL).
This code opens a print dialog. However, in kiosk mode, the print dialog will be bypassed, and the page will be automatically printed to the default printer.
Now you mentioned a PDF, and chances are, your generating it via PHP (if you are printing issued/generated files), your probably thinking "oh, well I can't put HTML in the PDF to execute the javascript". You don't need to! To solve the issue of printing the correct page, here's how:
Insert the following into an HTML/PHP page that the user is sent to (for this solution, the user does not need to visit the .pdf), in the <head> of the landing/success page:
<link rel="alternate" media="print" href="LINK TO PDF FILE">
If you have the above code in your page, when you execute window.print();, it will print the page specified above. If you don't save the PDF locally, you can put it in a temporary directory that is somehow (out of the scope of this question) cleared on a time based or action based schedule, to prevent disk space buildup.
Keep the following in mind:
Kiosk mode doesn't have an exit button. To exit, press ALT + F4.
When printing in kiosk mode, you need both --kiosk AND --kiosk-printing. The printing argument requires the --kiosk argument.
When printing in kiosk mode, it is normal for the print dialog to appear and then suddenly disappear. It can't be prevented without advanced window layering and whatnot.
I'm sure that other browsers have similar functionality to bypass the print dialog, however, I have found that Google Chrome works best in this kind of functionality. If your on a Linux machine, Google has a .deb file that you can install Google Chrome on Linux with, by using the command sudo dpkg -i (package / downloaded .deb file path). Chromium --might-- support this kind of functionality. As far as I know, it should.
If you need additional help, leave your question in the comments below, I'll respond ASAP.
I hope I helped. If I did, feel free to give me a green check to your left. ;)
I need a way to capture everything that is printed in my notebook.
Why?
I have a system, in PHP, and sometimes I need to print (php_printer) some invoices, but this costs a lot paper.
Printing is sent in the background without any popup windows for user confirmation.
So every time I send something to the printer, the windows (or any application) show me what was sent; or generate a PDF.
The problem is: How can I use this 'alternativa' without changing the printer (driver, etc). Because, if I do that, I need to test in 2 printers, and you know what I mean.
EscPos
This is the file that I used to print in windows or linux. I develop in windows (requirement of the company) but publish it in a linux server.
gist: https://gist.github.com/patrickmaciel/7673875
What I want
To capture every printed file and save it in a PDF or some driver/application in order to not print the file but rather show it to me on the screen (windows).
Setup
Dev OS (my): Windows 7 (Yes I know, but my employee only works with windows)
Prod OS: CentOS
Printer: TM-T88IV AFU (Epson)
To my question apparently no solution.
So I just edited it with the class and EscPos.php added a method to be executed after printing, writing a simplified way to print invoice in a txt file, which I monitor after filename.txt command tail-f.
Solution code: https://gist.github.com/patrickmaciel/7677891
Thanks guys.
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've found that I can print raw EPL2 commands to my Zebra 2844 (UPS) from Windows apps like Notepad and WordPad and get a nicely printed label using the Generic / Text driver in XP (couldn't get the actual Zebra drivers to do this much). But for some reason, I can not get it to print from IE8 (which is necessary for my php application). Nor from Firefox for that matter. When I print, the file goes to the printer's queue and quickly disappears. Nothing is printed.
I'm setting the header to Content-type: text/plain in php. But I've also tried loading the text file directly from the Desktop and printing with no luck.
Anyone run into this issue and have a solution? Perhaps there is a nuance in printing from a web browser that I'm not taking into consideration?
What you need is a way to get past the Windows Print layer, try this: http://code.google.com/p/jzebra/
It is a java applet that once you accept the security certificate can access the printer natively