mike42 / escpos-php Goto Github PK
View Code? Open in Web Editor NEWPHP library for printing to ESC/POS-compatible thermal and impact printers
License: Other
PHP library for printing to ESC/POS-compatible thermal and impact printers
License: Other
Dose this lib support printing HTML, else could you add this feature
Thank you,
Print directly using system fonts by generating images on-the-fly, to support non-monospace text, and any characters available on the host system, as an "ultimate back-up plan" for font compatibility issues.
Issue #6 appears to depend on this feature.
Many printers have vendor-specific or obscure code pages which are not supported by iconv.
These should be supported so that more languages & printers can be added.
do I need to create an $profile, and how! thanks.
I have some problems about Thai characters printing in Epson TM-T88V . I found that there is no codepage support of Thai characters in the source code .
how to make it support Thai characters? (TM-T88V also support Thai characters)
Thank you
Hello, I am using P-822D Thermal printer and everything is working great except from printing Greek characters (the are displayed as chinese)
Is there any settings i can do?
Thank you
I'm using the library ESCPOS-php. What code I'm using is this:
text ("Hello World! \ n"); $ printer -> cut (); $ printer -> close (); ?>I'm working locally with USB thermal printer under Windows 7 with PHP 5.2.17 . When you run the script I get this error:
[11-Aug-2015 19:58:37] PHP Parse error: syntax error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in C: \ Apache2.2 \ htdocs \ metropolis \ src \ AbstractCapabilityProfile.php on line 57
There are some installation manual to solve this error.
Just a small notice issue, it should be written like this:
if(!function_exists('imagecreatefrompng')) {
as if imagecreatefrompng
isn't encased with double single-quotes it will be defined as a constant.
This app work with Citizen printer ?
http://www.citizen-systems.com/us/printer/pos/ct-s601
Can I use this driver without composer? Do you a tutorial?
Can I print QRCode
Is there a command to get the status of the printer (online/offline), when the paper is ending or the paper is finished?
Lo he testeado en una FX-890 y el único problema es que no liberaba el papel luego determinar la impresión, para lo cual añadí la siguiente función:
class Escpos {
const FF = "\x0c";
function feed_form() {
$this -> connector -> write(self::FF);
}
Buen trabajo, Saludos.
Printing graphics is pretty easy. Is it possible to print them side by side rather than graphic1, next line, graphic2?
I am hoping to print graphic1 graphic2 then the line feed. Is this possible?
I'm using the TM-T20II and I use this function to set the font height and width
/* $w is in [1, 8].
* $w = 1: same size
* $w = 2: double width
* $w = 3: triple width and so on ...
* The same for $h but for height.
*/
function setSize($w, $h) {
$res = "\x1D\x21";
$w -= 1;
$h -= 1;
if ($w == 0 && $h == 0)
return;
return $res . chr((pow(2,4) * $w) + $h);
}
Hello,
Let me explain my problem, now, my PC call a php file which makes it a query on an API (it returns JSON) and return it manages to print the order if there is one.
I would like to make this printer one action without using my PC. It is a TM-T88V-i EPSON.
I do not manage to tell him that the connection is not IP but it is itself.
Thank you in advance
Use of a WindowsPrintConnector on Linux should invoke smbspool()
in the background to send the job.
Add a utility class (eg. EscposDocument) to convert a PDF into an array of EscposImage objects for printing.
Hi Mike,
Thanks for sharing the code, it works well except i'm having issue when printing image with bitImage. The image can be printed out nicely but very slow, can i know is there anyway to speed up the printing, any adjustment need to be done on the image?
My printer, according to the manual is ESC/POS compatible, and the library works well with this and other printers I have, however on this particular printer, It can't print images, sending an image to either of my OkiPos 80 Plus III printers results in the printer printing some garbled text, and then freezing, (I have to unplug it) I know it can print images, because I connected it to a computer running Windows 95, and it can print images; but perhaps it can't print images in the ESC/POS way?
Also note the library works very well with the following printers: ( I will add more as I can)
Epson:
Epson TM-T88III (graphics() yes, bitimage() yes, character test works too)
Okipos (Winbond/Nuvotron chip):
Okipos 80 Plus III (parallel interface, (graphics() no, bitimage() no, character test works too))
Zijiang (Chinese company, Winbond/Nuvotron used)
ZJ-5890T (USB interface , graphics() no, bitimage () yes)
ZJ-5870 (USB interface , graphics() no, bitimage () yes)
NT-58H (USB interface , graphics() no, bitimage () yes)
Xprinter (another Chinese company, higher quality than ZiJiang) (testing these in next couple days)
XP-T58K
XP-58III
XP-58IIIA
XP-58IIIK
XP-Q800 (80mm auto cutter) all functions apart from graphics works
XP-76IIN (label printer, 58mm)
Using a file pointer is not user-friendly enough. Escpos should instead be constructed with one of several "PrintConnector" classes, which handles opening/closing a file, network address, USB device, etc.
I just tried to get a Printer status from a TM-T88V via the NetworkPrintConnector class. However after issuing a getPrinterStatus(). I got an error stating:
ERR (3): exception 'ErrorException' with message 'rewind(): stream does not support seeking' in /path/to/php/vendor/mike42/escpos-php/src/FilePrintConnector.php:68
I tried to close then reopen the socket and even to comment out the rewind() that was there to no avail. Commenting out the rewind just made the library hang without putting out an error.
I might be missing something, but I'd like to get a status from the printer to find out if its working as expected before printing to it.
Hi @mike42 , my question is that if i want to use a shared printer from within the network, then which connector should i use?
Catchable fatal error: Argument 2 passed to EscposPrintBuffer::__construct() must implement interface PrintConnector, null given, called in C:\xampp\htdocs\escpos\Escpos.php on line 191 and defined in C:\xampp\htdocs\escpos\src\EscposPrintBuffer.php on line 89
Fatal error: Call to undefined function gzdecode() in C:\Apache2.2\htdocs\metropolis\src\EscposPrintBuffer.php on line 173
The print buffer now strips out non-printable characters to prevent user input from injecting commands. Add an example showing that data can still be sent to the print connector if the developer wants to send a command which is not available in the library.
I looked at the documentation that I can find. I cannot seem to find a way to print from a text file. I see that printing from html is possible. Is there a similar method for text files?
The first command-line example, $printer = new escpos();, will cause unclear PHP errors if run from a web app.
This should be detected, and a better error should be raised instead, telling the programmer that they need a file pointer.
Hello,
I am trying to use the print-from-html.php example and I am seeing an error regarding the file in /tmp/
Here is the error
Command wkhtmltoimage -n -q --width '550' 'http://en.m.wikipedia.org/wiki/ESC/P' '/tmp/escposZDsgxD.png' failed: PHP Notice: Print connector was not finalized. Did you forget to close the printer? in /usr/bin/escpos-php-master/src/FilePrintConnector.php on line 52
In the /tmp folder, I am finding the file without an extension.
Could this be the issue?
Fails with a fatal error if imagecreatefrompng()
(from GD extension) is unavailable and image output is attempted.
Improvements to try:
See also #13
i would like to thank you for this project, it makes my life a lot easy... i would like to request a new feature in this project. besides thermal printers can you enhance this to support cash drawers also?
Parse error: parse error, expecting T_STRING' or
T_VARIABLE' or `'$'' in D:\xampp\htdocs\swapv\library\escposphp\src\AbstractCapabilityProfile.php on line 57
what i see in the file is next:
public static final function getInstance() {
static $profile = null;
if ($profile === null) {
$profile = new static();
}
return $profile;
}
do you know the reason?
Hello, i´m new in php and I need print a ticket in a esc/pos thermal printer. Actually is connected in usb in Windows 7, can you help or guide me how can i do this using escpos-php, and also I need open a cash box. Thanks, any help is appreciated.
As the number of classes has increased, loading them all is a bit excessive.
Everything should be namespaced & have an auto-loader.
Hi Mike,
I am writing for another enhancement, I have a NV Logo uploaded to the printer memory, now I want to print that logo... If this functionality is already provided then I want to know the syntax for it.
When I send print from windows, the NV Logo is printed, but when I tried to print with this code, the NV Logo is not printing.
Thanks
Please visit this link and help me regarding printer issues. http://strikerinfotech.com/project/orderonline/update/
I'm trying to find a way to print receipts from my project. (It's SO difficult to find a good answer from the Web.):
I'm using Apache 2.4, PHP 5.6.3 and MySQL 5.6 on Windows 7 Pro 64-bit, with USB connected Epson TM-T20 II.
I'm so glad to find your wonderful work here. But when I used the "EscposTest.php" to test, I got the error msg: "Cannot initialize printer ... ".
(I did change the line in "Escpos.php" under "__construct" to=> $fp = fopen("EPSON TM-T20II Receipt", "wb");. I think I made a mistake somehow!)
My questions are:
Thanks again for your good job!
Trying to print with no luck on Star TSP143 via Ethernet, I have faced no error messages, nor anything that could give my understanding, what could be wrong.
I can print plain text via CUPS. And I can print on another printer Posiflex PP9000W via your library.
I will be very appreciated, if you could give me any clue at how I can debug this issue.
Add support for UTF-8 input in EscposPrintBuffer
, with automatic switching and conversion to alternate code pages where necessary,
This is an LTR, text-based version of #6
Hi,
How do I get euro symbol to work?
Whenever I modify your full-receipt-with-logo template and insert € instead of $, it prints some funny character.
How to get € symbol print?
Thanks
An error is given if Microsoft fonts are not installed.
Fonts should be configurable, with a public domain, widely available internationalised font being the default
Is there the ability (or a separate plugin) which would allow output text to a LCD Customer Display as well as the Thermal Printer? In my case they are daisy chained together so ideally output would need to target either the printer or the display.
The set of supported character encodings for this printer is not yet saved in a capability profile.
This needs to be added, along with an example, for Latvian text output.
Please add this driver :)
Hi Mike,
I am here with yet another change. I want to add Arabic Printing support for thermal printers also. can you please write a function to change the code page.
Thanks,
Sam
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.