Reputation: 211
I have a small tool for address collection. I want to print a particular address through my Thermal Printer. Database is MySQL..I do an AJAX query to list down all the addresses I want to search based on a particular requirement (for ex mobile number). Coding is in PhP and JQuery. I list them down as a table. Now I want to add a print button next to all individual address rows, on clicking of which, I want to print that particular address in my receipt printer.
Its just gonna be 2 lines of printing. If I simply copy the address to a new HTML page and print it, the problem is that printer doesnt stop just after 2 lines..it prints the entire white space below.
Sorry but have never done or worked on Printers before. Please can some one help me with this.
Upvotes: 0
Views: 3238
Reputation: 696
A quick fix will be to use a pop-up (or possibly an iFrame) of minimal dimensions but this will of course be tacky as far as the user experience, especially if this solution is part of a product/service you are providing to business customers.
WIN32 API: The proper way to do this requires some extra work on your end but well worth the time and effort, especially if you take on these types of projects often. Unfortunately it's a much more involved than writing a few lines of code and posting an answer for you.
STEP 1) Download the driver and documentation package for that printer. They usually have extensive developer documentation precisely for this reason. Skip to the Win32 API section. I found a package for your printer here: https://download.epson-biz.com/modules/pos/index.php?page=single_soft&cid=2783&scat=31&pcat=3
STEP 2) Look into the PHP Win32 API implementation and setup a couple test calls. Here's the link to the documentation: http://php.net/manual/en/ref.w32api.php
STEP 3) Setup a class/module/function that will lookup and print your address as needed from PHP.
STEP 4) To address printing when you eventually switch to a server/client setup, you can compile your PHP code into an executable, setup a mime type on each client that receives an address print file via the browser and sends it straight to your .exe file.
Long time ago I had to integrate ELTRON encoded magnetic stripe (credit card) printers with Perl for a large event management system. It worked like magic.
Again sorry this is not as easy as a few quick lines of code, but you can post more specific questions as you work your way through the printer API.
Good Luck.
Upvotes: 1
Reputation: 95020
All you can do for this is create an iframe that contains just what you want printed, then print it. How the printer handles that html will vary by printer and your code has no control over that.
Upvotes: 1