GithubHelp home page GithubHelp logo

mike42 / escpos-php Goto Github PK

View Code? Open in Web Editor NEW
2.5K 139.0 847.0 1.68 MB

PHP library for printing to ESC/POS-compatible thermal and impact printers

License: Other

PHP 94.32% HTML 5.68%
barcode epson receipt-printer printer php escpos hacktoberfest

escpos-php's Introduction

ESC/POS Print Driver for PHP

Build Status Latest Stable Version Total Downloads License Coverage Status

This project implements a subset of Epson's ESC/POS protocol for thermal receipt printers. It allows you to generate and print receipts with basic formatting, cutting, and barcodes on a compatible printer.

The library was developed to add drop-in support for receipt printing to any PHP app, including web-based point-of-sale (POS) applications.

Compatibility

Interfaces and operating systems

This driver is known to work with the following OS/interface combinations:

  Linux Mac Windows
Ethernet Yes Yes Yes
USB Yes Not tested Yes
USB-serial Yes Yes Yes
Serial Yes Yes Yes
Parallel Yes Not tested Yes
SMB shared Yes No Yes
CUPS hosted Yes Yes No

Printers

Many thermal receipt printers support ESC/POS to some degree. This driver has been known to work with:

  • 3nStar RPT-008
  • Approx APPPOS80AM
  • AURES ODP-333
  • AURES ODP-500
  • Bematech-4200-TH
  • Bematech LR2000E
  • Birch PRP-085III
  • Bixolon SRP-350III
  • Bixolon SRP-350Plus
  • Black Copper BC-85AC
  • CHD TH-305N
  • Citizen CBM1000-II
  • Citizen CT-S310II
  • Dapper-Geyi Q583P
  • Daruma DR800
  • DR-MP200 (manufacturer unknown)
  • EPOS TEP 220M
  • Elgin i9
  • Epson EU-T332C
  • Epson FX-890 (requires feedForm() to release paper).
  • Epson TM-T20
  • Epson TM-T20II
  • Epson TM-T70
  • Epson TM-T70II
  • Epson TM-T81
  • Epson TM-T82II
  • Epson TM-T88II
  • Epson TM-T88III
  • Epson TM-T88IV
  • Epson TM-T88V
  • Epson TM-U220
  • Epson TM-U295 (requires release() to release slip).
  • Epson TM-U590 and TM-U590P
  • Equal (EQ-IT-001) POS-58
  • Everycom EC-58
  • Excelvan HOP-E200
  • Excelvan HOP-E58
  • Excelvan HOP-E801
  • Gainscha GP-2120TF
  • Gainscha GP-5890x (Also marketed as EC Line 5890x)
  • Gainscha GP-U80300I (Also marketed as gprinter GP-U80300I)
  • gprinter GP-U80160I
  • HOIN HOP-H58
  • Ithaca iTherm 28
  • Hasar HTP 250
  • Metapace T-1
  • Metapace T-25
  • Nexa PX700
  • Nyear NP100
  • OKI RT322
  • OKI 80 Plus III
  • Orient BTP-R580
  • P-822D
  • P85A-401 (make unknown)
  • Partner Tech RP320
  • POSLIGNE ODP200H-III-G
  • QPOS Q58M
  • Rongta RP326US
  • Rongta RP58-U
  • Rongta RP80USE
  • SAM4S GIANT-100DB
  • Senor TP-100
  • Sewoo SLK-TS400
  • SEYPOS PRP-96
  • SEYPOS PRP-300 (Also marketed as TYSSO PRP-300)
  • SNBC BTP-R880NPIII
  • Solux SX-TP-88300
  • Sicar POS-80
  • Silicon SP-201 / RP80USE
  • SPRT SP-POS88V
  • Star BSC10
  • Star TSP100 ECO
  • Star TSP100III FuturePRNT
  • Star TSP-650
  • Star TUP-592
  • TVS RP45 Shoppe
  • Venus V248T
  • Xeumior SM-8330
  • Xprinter F-900
  • Xprinter XP-365B
  • Xprinter XP-58 Series
  • Xprinter XP-80C
  • Xprinter XP-90
  • XPrinter XP-Q20011
  • Xprinter XP-Q800
  • Zjiang NT-58H
  • Zjiang ZJ-5870
  • Zjiang ZJ-5890 (Also sold as POS-5890 by many vendors; ZJ-5890K, ZJ-5890T also work).
  • Zjiang ZJ-8220 (Also marketed as Excelvan ZJ-8220)
  • Zjiang ZJ-8250

If you use any other printer with this code, please let us know so that it can be added to the list.

Basic usage

Include the library

Composer

This library is designed for use with the composer PHP dependency manager. Simply add the mike42/escpos-php package to get started:

composer require mike42/escpos-php

If you haven't used composer before, you can read about it at getcomposer.org.

Requirements

This project has few hard dependencies:

  • PHP 7.3 or newer.
  • json extension, used to load bundled printer definitions (see documentation)
  • intl extension, used for character encoding (see documentation)
  • zlib extension, used for de-compressing bundled resources (see documentation).

It is also suggested that you install either imagick or gd, as these can be used to speed up image processing.

A number of optional extensions can be added to enable more specific features. These are described in the "suggest" section of composer.json.

The 'Hello World' receipt

To make use of this driver, your server (where PHP is installed) must be able to communicate with your printer. Start by generating a simple receipt and sending it to your printer using the command-line.

<?php
/* Call this file 'hello-world.php' */
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
$printer -> close();

Some examples are below for common interfaces.

Communicate with a printer with an Ethernet interface using netcat:

php hello-world.php | nc 10.x.x.x. 9100

A USB local printer connected with usblp on Linux has a device file (Includes USB-parallel interfaces):

php hello-world.php > /dev/usb/lp0

A computer installed into the local cups server is accessed through lp or lpr:

php hello-world.php > foo.txt
lpr -o raw -H localhost -P printer foo.txt

A local or networked printer on a Windows computer is mapped in to a file, and generally requires you to share the printer first:

php hello-world.php > foo.txt
net use LPT1 \\server\printer
copy foo.txt LPT1
del foo.txt

If you have troubles at this point, then you should consult your OS and printer system documentation to try to find a working print command.

Using a PrintConnector

To print receipts from PHP, use the most applicable PrintConnector for your setup. The connector simply provides the plumbing to get data to the printer.

For example, a NetworkPrintConnector accepts an IP address and port:

use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
use Mike42\Escpos\Printer;
$connector = new NetworkPrintConnector("10.x.x.x", 9100);
$printer = new Printer($connector);
try {
    // ... Print stuff
} finally {
    $printer -> close();
}

While a serial printer might use:

use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
$connector = new FilePrintConnector("/dev/ttyS0");
$printer = new Printer($connector);

For each OS/interface combination that's supported, there are examples in the compatibility section of how a PrintConnector would be constructed. If you can't get a PrintConnector to work, then be sure to include the working print command in your issue.

Using a CapabilityProfile

Support for commands and code pages varies between printer vendors and models. By default, the driver will accept UTF-8, and output commands that are suitable for Epson TM-series printers.

When trying out a new brand of printer, it's a good idea to use the "simple" CapabilityProfile, which instructs the driver to avoid the use of advanced features (generally simpler image handling, ASCII-only text).

use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\CapabilityProfile;
$profile = CapabilityProfile::load("simple");
$connector = new WindowsPrintConnector("smb://computer/printer");
$printer = new Printer($connector, $profile);

As another example, Star-branded printers use different commands:

use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
use Mike42\Escpos\CapabilityProfile;
$profile = CapabilityProfile::load("SP2000")
$connector = new WindowsPrintConnector("smb://computer/printer");
$printer = new Printer($connector, $profile);

For a list of available profiles, or to have support for your printer improved, please see the upstream receipt-print-hq/escpos-printer-db project.

Tips & examples

On Linux, your printer device file will be somewhere like /dev/lp0 (parallel), /dev/usb/lp1 (USB), /dev/ttyUSB0 (USB-Serial), /dev/ttyS0 (serial).

On Windows, the device files will be along the lines of LPT1 (parallel) or COM1 (serial). Use the WindowsPrintConnector to tap into system printing on Windows (eg. Windows USB, SMB or Windows LPT) - this submits print jobs via a queue rather than communicating directly with the printer.

A complete real-world receipt can be found in the code of Auth in ReceiptPrinter.php. It includes justification, boldness, and a barcode.

Other examples are located in the example/ directory.

Available methods

__construct(PrintConnector $connector, CapabilityProfile $profile)

Construct new print object.

Parameters:

  • PrintConnector $connector: The PrintConnector to send data to.
  • CapabilityProfile $profile Supported features of this printer. If not set, the "default" CapabilityProfile will be used, which is suitable for Epson printers.

See example/interface/ for ways to open connections for different platforms and interfaces.

barcode($content, $type)

Print a barcode.

Parameters:

  • string $content: The information to encode.
  • int $type: The barcode standard to output. If not specified, Printer::BARCODE_CODE39 will be used.

Currently supported barcode standards are (depending on your printer):

  • BARCODE_UPCA
  • BARCODE_UPCE
  • BARCODE_JAN13
  • BARCODE_JAN8
  • BARCODE_CODE39
  • BARCODE_ITF
  • BARCODE_CODABAR

Note that some barcode standards can only encode numbers, so attempting to print non-numeric codes with them may result in strange behaviour.

bitImage(EscposImage $image, $size)

See graphics() below.

cut($mode, $lines)

Cut the paper.

Parameters:

  • int $mode: Cut mode, either Printer::CUT_FULL or Printer::CUT_PARTIAL. If not specified, Printer::CUT_FULL will be used.
  • int $lines: Number of lines to feed before cutting. If not specified, 3 will be used.

feed($lines)

Print and feed line / Print and feed n lines.

Parameters:

  • int $lines: Number of lines to feed

feedForm()

Some printers require a form feed to release the paper. On most printers, this command is only useful in page mode, which is not implemented in this driver.

feedReverse($lines)

Print and reverse feed n lines.

Parameters:

  • int $lines: number of lines to feed. If not specified, 1 line will be fed.

graphics(EscposImage $image, $size)

Print an image to the printer.

Parameters:

  • EscposImage $img: The image to print.
  • int $size: Output size modifier for the image.

Size modifiers are:

  • IMG_DEFAULT (leave image at original size)
  • IMG_DOUBLE_WIDTH
  • IMG_DOUBLE_HEIGHT

A minimal example:

<?php
$img = EscposImage::load("logo.png");
$printer -> graphics($img);

See the example/ folder for detailed examples.

The function bitImage() takes the same parameters, and can be used if your printer doesn't support the newer graphics commands. As an additional fallback, the bitImageColumnFormat() function is also provided.

initialize()

Initialize printer. This resets formatting back to the defaults.

pdf417Code($content, $width, $heightMultiplier, $dataColumnCount, $ec, $options)

Print a two-dimensional data code using the PDF417 standard.

Parameters:

  • string $content: Text or numbers to store in the code
  • number $width: Width of a module (pixel) in the printed code. Default is 3 dots.
  • number $heightMultiplier: Multiplier for height of a module. Default is 3 times the width.
  • number $dataColumnCount: Number of data columns to use. 0 (default) is to auto-calculate. Smaller numbers will result in a narrower code, making larger pixel sizes possible. Larger numbers require smaller pixel sizes.
  • real $ec: Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%).
  • number $options: Standard code Printer::PDF417_STANDARD with start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only.

pulse($pin, $on_ms, $off_ms)

Generate a pulse, for opening a cash drawer if one is connected. The default settings (0, 120, 240) should open an Epson drawer.

Parameters:

  • int $pin: 0 or 1, for pin 2 or pin 5 kick-out connector respectively.
  • int $on_ms: pulse ON time, in milliseconds.
  • int $off_ms: pulse OFF time, in milliseconds.

qrCode($content, $ec, $size, $model)

Print the given data as a QR code on the printer.

  • string $content: The content of the code. Numeric data will be more efficiently compacted.
  • int $ec Error-correction level to use. One of Printer::QR_ECLEVEL_L (default), Printer::QR_ECLEVEL_M, Printer::QR_ECLEVEL_Q or Printer::QR_ECLEVEL_H. Higher error correction results in a less compact code.
  • int $size: Pixel size to use. Must be 1-16 (default 3)
  • int $model: QR code model to use. Must be one of Printer::QR_MODEL_1, Printer::QR_MODEL_2 (default) or Printer::QR_MICRO (not supported by all printers).

selectPrintMode($mode)

Select print mode(s).

Parameters:

  • int $mode: The mode to use. Default is Printer::MODE_FONT_A, with no special formatting. This has a similar effect to running initialize().

Several MODE_* constants can be OR'd together passed to this function's $mode argument. The valid modes are:

  • MODE_FONT_A
  • MODE_FONT_B
  • MODE_EMPHASIZED
  • MODE_DOUBLE_HEIGHT
  • MODE_DOUBLE_WIDTH
  • MODE_UNDERLINE

setBarcodeHeight($height)

Set barcode height.

Parameters:

  • int $height: Height in dots. If not specified, 8 will be used.

setBarcodeWidth($width)

Set barcode bar width.

Parameters:

  • int $width: Bar width in dots. If not specified, 3 will be used. Values above 6 appear to have no effect.

setColor($color)

Select print color - on printers that support multiple colors.

Parameters:

  • int $color: Color to use. Must be either Printer::COLOR_1 (default), or Printer::COLOR_2

setDoubleStrike($on)

Turn double-strike mode on/off.

Parameters:

  • boolean $on: true for double strike, false for no double strike.

setEmphasis($on)

Turn emphasized mode on/off.

Parameters:

  • boolean $on: true for emphasis, false for no emphasis.

setFont($font)

Select font. Most printers have two fonts (Fonts A and B), and some have a third (Font C).

Parameters:

  • int $font: The font to use. Must be either Printer::FONT_A, Printer::FONT_B, or Printer::FONT_C.

setJustification($justification)

Select justification.

Parameters:

  • int $justification: One of Printer::JUSTIFY_LEFT, Printer::JUSTIFY_CENTER, or Printer::JUSTIFY_RIGHT.

setLineSpacing($height)

Set the height of the line.

Some printers will allow you to overlap lines with a smaller line feed.

Parameters:

  • int $height: The height of each line, in dots. If not set, the printer will reset to its default line spacing.

setPrintLeftMargin($margin)

Set print area left margin. Reset to default with Printer::initialize().

Parameters:

  • int $margin: The left margin to set on to the print area, in dots.

setPrintWidth($width)

Set print area width. This can be used to add a right margin to the print area. Reset to default with Printer::initialize().

Parameters:

  • int $width: The width of the page print area, in dots.

setReverseColors($on)

Set black/white reverse mode on or off. In this mode, text is printed white on a black background.

Parameters:

  • boolean $on: True to enable, false to disable.

setTextSize($widthMultiplier, $heightMultiplier)

Set the size of text, as a multiple of the normal size.

Parameters:

  • int $widthMultiplier: Multiple of the regular height to use (range 1 - 8).
  • int $heightMultiplier: Multiple of the regular height to use (range 1 - 8).

setUnderline($underline)

Set underline for printed text.

Parameters:

  • int $underline: Either true/false, or one of Printer::UNDERLINE_NONE, Printer::UNDERLINE_SINGLE or Printer::UNDERLINE_DOUBLE. Defaults to Printer::UNDERLINE_SINGLE.

text($str)

Add text to the buffer. Text should either be followed by a line-break, or feed() should be called after this.

Parameters:

  • string $str: The string to print.

Further notes

Posts I've written up for people who are learning how to use receipt printers:

Development

This code is MIT licensed, and you are encouraged to contribute any modifications back to the project.

For development, it's suggested that you load imagick, gd and Xdebug PHP extensions.

The tests are executed on Travis CI over PHP 7.3, 7.4 and 8.0. Older versions of PHP are not supported in the current release, nor is HHVM.

Fetch a copy of this code and load dependencies with composer:

git clone https://github.com/mike42/escpos-php
cd escpos-php/
composer install

Execute unit tests via phpunit:

php vendor/bin/phpunit --coverage-text

This project uses the PSR-2 standard, which can be checked via PHP_CodeSniffer:

php vendor/bin/phpcs --standard=psr2 src/ -n

The developer docs are build with doxygen. Re-build them to check for documentation warnings:

make -C doc clean && make -C doc

Pull requests and bug reports welcome.

escpos-php's People

Contributors

ablunier avatar alif25r avatar bgarret avatar daveferger avatar f avatar jankal avatar marech avatar matiasgaston avatar mike42 avatar msorri avatar robertocortina avatar stenerson avatar thicolares avatar wavoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

escpos-php's Issues

BitImage Slow

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?

Image

I print the receipt but the image is not printed.
001

Namespaces, autoloading

As the number of classes has increased, loading them all is a bit excessive.

Everything should be namespaced & have an auto-loader.

Image-based print buffer

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.

Output to Customer Display Turret

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.

Image loading input formats: add jpg, bmp support, ImageMagick fallback

Fails with a fatal error if imagecreatefrompng() (from GD extension) is unavailable and image output is attempted.

Improvements to try:

  • Throw an exception instead
  • Auto-fallback on Imagemagick
  • Support JPEG loading via ImageMagick or Gd also
  • Contain a simple BMP loader, as some printers can directly load BMP data, removing the need for libraries.

See also #13

Windows 7 USB print support question

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.

Greek character printing

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

Add support for right-to-left text output

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

Support non-iconv code pages

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.

Support HTML print

Dose this lib support printing HTML, else could you add this feature

Thank you,

Testeado en FX-890

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.

Euro Symbol €

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

NetworkPrintConnector attempts to rewind a network connected stream

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.

Open cash drawer

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?

Font handling in ImagePrintBuffer

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

graphics() and bitimage() not working on Okipos 80 Plus III

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)

Star TSP143

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.

Print from USB connected printer under Windows

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:

  1. Does the codes only worked under Linux? (if it does, do you have anything works under Windows?)
  2. I saw your blog gave examples to setup Ethernet connected printer, but how can I setup the USB connected printer?
  3. How do I setup my printer under your codes in Escpos.php?
  4. I assume that with your codes, I don't need to set the "php-printer" extension under "php.ini" right?

Thanks again for your good job!

Hello i am having the issue below...

Parse error: parse error, expecting T_STRING' orT_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;
}

Apache Version Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.8

do you know the reason?

Star TUP 592 Printer capability profile

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.

AbstractCapabilityProfile

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.

Graphical output - Print logo

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

Graphics side by side

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?

PDF print support

Add a utility class (eg. EscposDocument) to convert a PDF into an array of EscposImage objects for printing.

Linux Samba printing

Use of a WindowsPrintConnector on Linux should invoke smbspool() in the background to send the job.

Support for UTF-8 input

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

how to fix this?

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

print-from-html.php /tmp issue?

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?

Set font height and width

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);
}

Self-printer

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

print from txt file

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?

Thai characters printing

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

Provide "print connectors" for different interfaces

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.

Get status of the printer

Is there a command to get the status of the printer (online/offline), when the paper is ending or the paper is finished?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.