<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.8">
  <compounddef id="indexpage" kind="page">
    <compoundname>index</compoundname>
    <title>escpos-php</title>
    <detaileddescription>
<para><ulink url="https://travis-ci.org/mike42/escpos-php">![Build Status](https://travis-ci.org/mike42/escpos-php.svg?branch=master)</ulink> <ulink url="https://packagist.org/packages/mike42/escpos-php">![Latest Stable Version](https://poser.pugx.org/mike42/escpos-php/v/stable)</ulink> <ulink url="https://packagist.org/packages/mike42/escpos-php">![Total Downloads](https://poser.pugx.org/mike42/escpos-php/downloads)</ulink> <ulink url="https://packagist.org/packages/mike42/escpos-php">![License](https://poser.pugx.org/mike42/escpos-php/license)</ulink> <ulink url="https://coveralls.io/github/mike42/escpos-php?branch=development">![Coverage Status](https://coveralls.io/repos/github/mike42/escpos-php/badge.svg?branch=development)</ulink></para><para>This project implements a subset of Epson&apos;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.</para><para>The library was developed to add drop-in support for receipt printing to any PHP app, including web-based point-of-sale (POS) applications.</para><para><heading level="2">Compatibility</heading>
</para><para><heading level="3">Interfaces and operating systems</heading>
</para><para>This driver is known to work with the following OS/interface combinations:</para><para><table rows="8" cols="4"><row>
<entry thead="yes"><para><nonbreakablespace/> </para></entry><entry thead="yes"><para>Linux </para></entry><entry thead="yes"><para>Mac </para></entry><entry thead="yes"><para>Windows  </para></entry></row>
<row>
<entry thead="yes"><para>Ethernet </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php">Yes</ulink> </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php">Yes</ulink> </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php">Yes</ulink>  </para></entry></row>
<row>
<entry thead="yes"><para>USB </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/linux-usb.php">Yes</ulink> </para></entry><entry thead="no"><para>Not tested </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/windows-usb.php">Yes</ulink>  </para></entry></row>
<row>
<entry thead="yes"><para>USB-serial </para></entry><entry thead="no"><para>Yes </para></entry><entry thead="no"><para>Yes </para></entry><entry thead="no"><para>Yes  </para></entry></row>
<row>
<entry thead="yes"><para>Serial </para></entry><entry thead="no"><para>Yes </para></entry><entry thead="no"><para>Yes </para></entry><entry thead="no"><para>Yes  </para></entry></row>
<row>
<entry thead="yes"><para>Parallel </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/windows-lpt.php">Yes</ulink> </para></entry><entry thead="no"><para>Not tested </para></entry><entry thead="no"><para>Yes  </para></entry></row>
<row>
<entry thead="yes"><para>SMB shared </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php">Yes</ulink> </para></entry><entry thead="no"><para>No </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php">Yes</ulink>  </para></entry></row>
<row>
<entry thead="yes"><para>CUPS hosted </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/cups.php">Yes</ulink> </para></entry><entry thead="no"><para><ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/cups.php">Yes</ulink> </para></entry><entry thead="no"><para>No  </para></entry></row>
</table>
</para><para><heading level="3">Printers</heading>
</para><para>Many thermal receipt printers support ESC/POS to some degree. This driver has been known to work with:</para><para><itemizedlist>
<listitem><para>3nStrat POS-08</para></listitem><listitem><para>AURES ODP-333</para></listitem><listitem><para>AURES ODP-500</para></listitem><listitem><para>Bematech-4200-TH</para></listitem><listitem><para>Bematech LR2000E</para></listitem><listitem><para>Bixolon SRP-350III</para></listitem><listitem><para>Black Copper BC-85AC</para></listitem><listitem><para>Citizen CBM1000-II</para></listitem><listitem><para>Citizen CT-S310II</para></listitem><listitem><para>Dapper-Geyi Q583P</para></listitem><listitem><para>Daruma DR800</para></listitem><listitem><para>DR-MP200 (manufacturer unknown)</para></listitem><listitem><para>EPOS TEP 220M</para></listitem><listitem><para>Epson EU-T332C</para></listitem><listitem><para>Epson FX-890 (requires <computeroutput>feedForm()</computeroutput> to release paper).</para></listitem><listitem><para>Epson TM-T20</para></listitem><listitem><para>Epson TM-T20II</para></listitem><listitem><para>Epson TM-T70</para></listitem><listitem><para>Epson TM-T70II</para></listitem><listitem><para>Epson TM-T81</para></listitem><listitem><para>Epson TM-T82II</para></listitem><listitem><para>Epson TM-T88II</para></listitem><listitem><para>Epson TM-T88III</para></listitem><listitem><para>Epson TM-T88IV</para></listitem><listitem><para>Epson TM-T88V</para></listitem><listitem><para>Epson TM-U220</para></listitem><listitem><para>Epson TM-U295 (requires <computeroutput>release()</computeroutput> to release slip).</para></listitem><listitem><para>Epson TM-U590 and TM-U590P</para></listitem><listitem><para>Equal (EQ-IT-001) POS-58</para></listitem><listitem><para>Excelvan HOP-E200</para></listitem><listitem><para>Excelvan HOP-E58</para></listitem><listitem><para>Excelvan HOP-E801</para></listitem><listitem><para>Excelvan ZJ-8220</para></listitem><listitem><para>Gainscha GP-5890x (Also marketed as EC Line 5890x)</para></listitem><listitem><para>Gainscha GP-U80300I (Also marketed as gprinter GP-U80300I)</para></listitem><listitem><para>gprinter GP-U80160I</para></listitem><listitem><para>Hasar HTP 250</para></listitem><listitem><para>Metapace T-1</para></listitem><listitem><para>Metapace T-25</para></listitem><listitem><para>Nexa PX700</para></listitem><listitem><para>Nyear NP100</para></listitem><listitem><para>Okipos 80 Plus III</para></listitem><listitem><para>Orient BTP-R580</para></listitem><listitem><para>Partner Tech RP320</para></listitem><listitem><para>P-822D</para></listitem><listitem><para>P85A-401 (make unknown)</para></listitem><listitem><para>Rongta RP326US</para></listitem><listitem><para>Rongta RP58-U</para></listitem><listitem><para>Senor TP-100</para></listitem><listitem><para>SEYPOS PRP-300 (Also marketed as TYSSO PRP-300)</para></listitem><listitem><para>Sicar POS-80</para></listitem><listitem><para>Silicon SP-201 / RP80USE</para></listitem><listitem><para>SPRT SP-POS88V</para></listitem><listitem><para>Star BSC10</para></listitem><listitem><para>Star TSP100 ECO</para></listitem><listitem><para>Star TSP100III FuturePRNT</para></listitem><listitem><para>Star TSP-650</para></listitem><listitem><para>Star TUP-592</para></listitem><listitem><para>Venus V248T</para></listitem><listitem><para>Xprinter F-900</para></listitem><listitem><para>Xprinter XP-365B</para></listitem><listitem><para>Xprinter XP-58 Series</para></listitem><listitem><para>Xprinter XP-80C</para></listitem><listitem><para>Xprinter XP-90</para></listitem><listitem><para>XPrinter XP-Q20011</para></listitem><listitem><para>Xprinter XP-Q800</para></listitem><listitem><para>Zjiang NT-58H</para></listitem><listitem><para>Zjiang ZJ-5870</para></listitem><listitem><para>Zjiang ZJ-5890K</para></listitem><listitem><para>Zjiang ZJ-5890T (Marketed as POS 5890T)</para></listitem><listitem><para>Zjiang ZJ-8220</para></listitem></itemizedlist>
</para><para>If you use any other printer with this code, please <ulink url="https://github.com/mike42/escpos-php/issues/new">let us know</ulink> so that it can be added to the list.</para><para><heading level="2">Basic usage</heading>
</para><para><heading level="3">Include the library</heading>
</para><para><heading level="4">Composer</heading>
</para><para>If you are using composer, then add <computeroutput>mike42/escpos-php</computeroutput> as a dependency:</para><para>```bash composer require mike42/escpos-php ```</para><para>In this case, you would include composer&apos;s auto-loader at the top of your source files:</para><para>```php &lt;?php require <bold>DIR</bold> . &apos;/vendor/autoload.php&apos;; ```</para><para><heading level="4">Manually</heading>
</para><para>If you don&apos;t have composer available, then simply download the code and include <computeroutput>autoload.php</computeroutput>:</para><para>```bash git clone <ulink url="https://github.com/mike42/escpos-php">https://github.com/mike42/escpos-php</ulink> vendor/mike42/escpos-php ```</para><para>```php &lt;?php require <bold>DIR</bold> . &apos;/vendor/mike42/escpos-php/autoload.php&apos;; ```</para><para><heading level="4">Requirements</heading>
</para><para>To maintain compatibility with as many systems as possible, this driver has few hard dependencies:</para><para><itemizedlist>
<listitem><para>PHP 5.4 or above.</para></listitem><listitem><para><computeroutput>mbstring</computeroutput> extension, since the driver accepts UTF-8 encoding.</para></listitem></itemizedlist>
</para><para>It is also suggested that you install either <computeroutput>imagick</computeroutput> or <computeroutput>gd</computeroutput>, so that you can print images.</para><para>A number of optional packages can be added to enable more specific features. These are described in the &quot;suggest&quot; section of <ulink url="https://github.com/mike42/escpos-php/tree/master/composer.json">composer.json</ulink>.</para><para><heading level="3">The &apos;Hello World&apos; receipt</heading>
</para><para>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.</para><para>```php &lt;?php /* Call this file &apos;hello-world.php&apos; */ require <bold>DIR</bold> . &apos;/vendor/autoload.php&apos;; use Mike42; use Mike42; $connector = new FilePrintConnector(&quot;php://stdout&quot;); $printer = new Printer($connector); $printer -&gt; text(&quot;Hello World!\n&quot;); $printer -&gt; cut(); $printer -&gt; close(); ```</para><para>Some examples are below for common interfaces.</para><para>Communicate with a printer with an Ethernet interface using <computeroutput>netcat</computeroutput>:</para><para>```bash php hello-world.php | nc 10.x.x.x. 9100 ```</para><para>A USB local printer connected with <computeroutput>usblp</computeroutput> on Linux has a device file (Includes USB-parallel interfaces):</para><para>```bash php hello-world.php &gt; /dev/usb/lp0 ```</para><para>A computer installed into the local <computeroutput>cups</computeroutput> server is accessed through <computeroutput>lp</computeroutput> or <computeroutput>lpr</computeroutput>:</para><para>```bash php hello-world.php &gt; foo.txt lpr -o raw -H localhost -P printer foo.txt ```</para><para>A local or networked printer on a Windows computer is mapped in to a file, and generally requires you to share the printer first:</para><para>``` php hello-world.php &gt; foo.txt net use LPT1 \server copy foo.txt LPT1 del foo.txt ```</para><para>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.</para><para><heading level="3">Using a PrintConnector</heading>
</para><para>To print receipts from PHP, use the most applicable <ulink url="https://github.com/mike42/escpos-php/tree/master/src/Mike42/Escpos/PrintConnectors">PrintConnector</ulink> for your setup. The connector simply provides the plumbing to get data to the printer.</para><para>For example, a <computeroutput>NetworkPrintConnector</computeroutput> accepts an IP address and port:</para><para>```php use Mike42; use Mike42; $connector = new NetworkPrintConnector(&quot;10.x.x.x&quot;, 9100); $printer = new Printer($connector); try { // ... Print stuff } finally { $printer -&gt; close(); } ```</para><para>While a serial printer might use: ```php use Mike42; use Mike42; $connector = new FilePrintConnector(&quot;/dev/ttyS0&quot;); $printer = new Printer($connector); ```</para><para>For each OS/interface combination that&apos;s supported, there are examples in the compatibility section of how a <computeroutput>PrintConnector</computeroutput> would be constructed. If you can&apos;t get a <computeroutput>PrintConnector</computeroutput> to work, then be sure to include the working print command in bug.</para><para><heading level="3">Using a CapabilityProfile</heading>
</para><para>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.</para><para>When trying out a new brand of printer, it&apos;s a good idea to use the &quot;simple&quot; <computeroutput>CapabilityProfile</computeroutput>, which instructs the driver to avoid the use of advanced features (generally simpler image handling, ASCII-only text).</para><para>```php use Mike42; use Mike42; $profile = CapabilityProfile::load(&quot;simple&quot;); $connector = new WindowsPrintConnector(&quot;smb://computer/printer&quot;); $printer = new Printer($connector, $profile); ```</para><para>As another example, Star-branded printers use different commands:</para><para>```php use Mike42; use Mike42; $profile = CapabilityProfile::load(&quot;SP2000&quot;) $connector = new WindowsPrintConnector(&quot;smb://computer/printer&quot;); $printer = new Printer($connector, $profile); ```</para><para>For a list of available profiles, or to have support for your printer improved, please see the upstream <ulink url="https://github.com/receipt-print-hq/escpos-printer-db">receipt-print-hq/escpos-printer-db</ulink> project.</para><para><heading level="3">Tips &amp; examples</heading>
</para><para>On Linux, your printer device file will be somewhere like <computeroutput>/dev/lp0</computeroutput> (parallel), <computeroutput>/dev/usb/lp1</computeroutput> (USB), <computeroutput>/dev/ttyUSB0</computeroutput> (USB-Serial), <computeroutput>/dev/ttyS0</computeroutput> (serial).</para><para>On Windows, the device files will be along the lines of <computeroutput>LPT1</computeroutput> (parallel) or <computeroutput>COM1</computeroutput> (serial). Use the <computeroutput>WindowsPrintConnector</computeroutput> to tap into system printing on Windows (eg. <ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/windows-usb.php">Windows USB</ulink>, <ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php">SMB</ulink> or <ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/windows-lpt.php">Windows LPT</ulink>) - this submits print jobs via a queue rather than communicating directly with the printer.</para><para>A complete real-world receipt can be found in the code of <ulink url="https://github.com/mike42/Auth">Auth</ulink> in <ulink url="https://github.com/mike42/Auth/blob/master/lib/misc/ReceiptPrinter.php">ReceiptPrinter.php</ulink>. It includes justification, boldness, and a barcode.</para><para>Other examples are located in the <ulink url="https://github.com/mike42/escpos-php/blob/master/example/">example/</ulink> directory.</para><para><heading level="2">Available methods</heading>
</para><para><heading level="3">__construct(PrintConnector $connector, CapabilityProfile $profile)</heading>
</para><para>Construct new print object.</para><para>Parameters:<itemizedlist>
<listitem><para><computeroutput>PrintConnector $connector</computeroutput>: The PrintConnector to send data to.</para></listitem><listitem><para><computeroutput>CapabilityProfile $profile</computeroutput> Supported features of this printer. If not set, the &quot;default&quot; CapabilityProfile will be used, which is suitable for Epson printers.</para></listitem></itemizedlist>
</para><para>See <ulink url="https://github.com/mike42/escpos-php/tree/master/example/interface/">example/interface/</ulink> for ways to open connections for different platforms and interfaces.</para><para><heading level="3">barcode($content, $type)</heading>
</para><para>Print a barcode.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>string $content</computeroutput>: The information to encode.</para></listitem><listitem><para><computeroutput>int $type</computeroutput>: The barcode standard to output. If not specified, <computeroutput>Printer::BARCODE_CODE39</computeroutput> will be used.</para></listitem></itemizedlist>
</para><para>Currently supported barcode standards are (depending on your printer):</para><para><itemizedlist>
<listitem><para><computeroutput>BARCODE_UPCA</computeroutput></para></listitem><listitem><para><computeroutput>BARCODE_UPCE</computeroutput></para></listitem><listitem><para><computeroutput>BARCODE_JAN13</computeroutput></para></listitem><listitem><para><computeroutput>BARCODE_JAN8</computeroutput></para></listitem><listitem><para><computeroutput>BARCODE_CODE39</computeroutput></para></listitem><listitem><para><computeroutput>BARCODE_ITF</computeroutput></para></listitem><listitem><para><computeroutput>BARCODE_CODABAR</computeroutput></para></listitem></itemizedlist>
</para><para>Note that some barcode standards can only encode numbers, so attempting to print non-numeric codes with them may result in strange behaviour.</para><para><heading level="3">bitImage(EscposImage $image, $size)</heading>
</para><para>See <ulink url="#graphicsescposimage-image-size">graphics()</ulink> below.</para><para><heading level="3">cut($mode, $lines)</heading>
</para><para>Cut the paper.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $mode</computeroutput>: Cut mode, either <computeroutput>Printer::CUT_FULL</computeroutput> or <computeroutput>Printer::CUT_PARTIAL</computeroutput>. If not specified, <computeroutput>Printer::CUT_FULL</computeroutput> will be used.</para></listitem><listitem><para><computeroutput>int $lines</computeroutput>: Number of lines to feed before cutting. If not specified, 3 will be used.</para></listitem></itemizedlist>
</para><para><heading level="3">feed($lines)</heading>
</para><para>Print and feed line / Print and feed n lines.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $lines</computeroutput>: Number of lines to feed</para></listitem></itemizedlist>
</para><para><heading level="3">feedForm()</heading>
</para><para>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.</para><para><heading level="3">feedReverse($lines)</heading>
</para><para>Print and reverse feed n lines.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $lines</computeroutput>: number of lines to feed. If not specified, 1 line will be fed.</para></listitem></itemizedlist>
</para><para><heading level="3">graphics(EscposImage $image, $size)</heading>
</para><para>Print an image to the printer.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>EscposImage $img</computeroutput>: The image to print.</para></listitem><listitem><para><computeroutput>int $size</computeroutput>: Output size modifier for the image.</para></listitem></itemizedlist>
</para><para>Size modifiers are:</para><para><itemizedlist>
<listitem><para><computeroutput>IMG_DEFAULT</computeroutput> (leave image at original size)</para></listitem><listitem><para><computeroutput>IMG_DOUBLE_WIDTH</computeroutput></para></listitem><listitem><para><computeroutput>IMG_DOUBLE_HEIGHT</computeroutput></para></listitem></itemizedlist>
</para><para>A minimal example:</para><para>```php &lt;?php $img = EscposImage::load(&quot;logo.png&quot;); $printer -&gt; graphics($img); ```</para><para>See the <ulink url="https://github.com/mike42/escpos-php/blob/master/example/">example/</ulink> folder for detailed examples.</para><para>The function <ulink url="#bitimageescposimage-image-size">bitImage()</ulink> takes the same parameters, and can be used if your printer doesn&apos;t support the newer graphics commands. As an additional fallback, the <computeroutput>bitImageColumnFormat()</computeroutput> function is also provided.</para><para><heading level="3">initialize()</heading>
</para><para>Initialize printer. This resets formatting back to the defaults.</para><para><heading level="3">pdf417Code($content, $width, $heightMultiplier, $dataColumnCount, $ec, $options)</heading>
</para><para>Print a two-dimensional data code using the PDF417 standard.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>string $content</computeroutput>: Text or numbers to store in the code</para></listitem><listitem><para><computeroutput>number $width</computeroutput>: Width of a module (pixel) in the printed code. Default is 3 dots.</para></listitem><listitem><para><computeroutput>number $heightMultiplier</computeroutput>: Multiplier for height of a module. Default is 3 times the width.</para></listitem><listitem><para><computeroutput>number $dataColumnCount</computeroutput>: 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.</para></listitem><listitem><para><computeroutput>real $ec</computeroutput>: Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%).</para></listitem><listitem><para><computeroutput>number $options</computeroutput>: Standard code <computeroutput>Printer::PDF417_STANDARD</computeroutput> with start/end bars, or truncated code <computeroutput>Printer::PDF417_TRUNCATED</computeroutput> with start bars only.</para></listitem></itemizedlist>
</para><para><heading level="3">pulse($pin, $on_ms, $off_ms)</heading>
</para><para>Generate a pulse, for opening a cash drawer if one is connected. The default settings (0, 120, 240) should open an Epson drawer.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $pin</computeroutput>: 0 or 1, for pin 2 or pin 5 kick-out connector respectively.</para></listitem><listitem><para><computeroutput>int $on_ms</computeroutput>: pulse ON time, in milliseconds.</para></listitem><listitem><para><computeroutput>int $off_ms</computeroutput>: pulse OFF time, in milliseconds.</para></listitem></itemizedlist>
</para><para><heading level="3">qrCode($content, $ec, $size, $model)</heading>
</para><para>Print the given data as a QR code on the printer.</para><para><itemizedlist>
<listitem><para><computeroutput>string $content</computeroutput>: The content of the code. Numeric data will be more efficiently compacted.</para></listitem><listitem><para><computeroutput>int $ec</computeroutput> Error-correction level to use. One of <computeroutput>Printer::QR_ECLEVEL_L</computeroutput> (default), <computeroutput>Printer::QR_ECLEVEL_M</computeroutput>, <computeroutput>Printer::QR_ECLEVEL_Q</computeroutput> or <computeroutput>Printer::QR_ECLEVEL_H</computeroutput>. Higher error correction results in a less compact code.</para></listitem><listitem><para><computeroutput>int $size</computeroutput>: Pixel size to use. Must be 1-16 (default 3)</para></listitem><listitem><para><computeroutput>int $model</computeroutput>: QR code model to use. Must be one of <computeroutput>Printer::QR_MODEL_1</computeroutput>, <computeroutput>Printer::QR_MODEL_2</computeroutput> (default) or <computeroutput>Printer::QR_MICRO</computeroutput> (not supported by all printers).</para></listitem></itemizedlist>
</para><para><heading level="3">selectPrintMode($mode)</heading>
</para><para>Select print mode(s).</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $mode</computeroutput>: The mode to use. Default is <computeroutput>Printer::MODE_FONT_A</computeroutput>, with no special formatting. This has a similar effect to running <computeroutput>initialize()</computeroutput>.</para></listitem></itemizedlist>
</para><para>Several MODE_* constants can be OR&apos;d together passed to this function&apos;s <computeroutput>$mode</computeroutput> argument. The valid modes are:</para><para><itemizedlist>
<listitem><para><computeroutput>MODE_FONT_A</computeroutput></para></listitem><listitem><para><computeroutput>MODE_FONT_B</computeroutput></para></listitem><listitem><para><computeroutput>MODE_EMPHASIZED</computeroutput></para></listitem><listitem><para><computeroutput>MODE_DOUBLE_HEIGHT</computeroutput></para></listitem><listitem><para><computeroutput>MODE_DOUBLE_WIDTH</computeroutput></para></listitem><listitem><para><computeroutput>MODE_UNDERLINE</computeroutput></para></listitem></itemizedlist>
</para><para><heading level="3">setBarcodeHeight($height)</heading>
</para><para>Set barcode height.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $height</computeroutput>: Height in dots. If not specified, 8 will be used.</para></listitem></itemizedlist>
</para><para><heading level="3">setBarcodeWidth($width)</heading>
</para><para>Set barcode bar width.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $width</computeroutput>: Bar width in dots. If not specified, 3 will be used. Values above 6 appear to have no effect.</para></listitem></itemizedlist>
</para><para><heading level="3">setColor($color)</heading>
</para><para>Select print color - on printers that support multiple colors.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $color</computeroutput>: Color to use. Must be either <computeroutput>Printer::COLOR_1</computeroutput> (default), or <computeroutput>Printer::COLOR_2</computeroutput></para></listitem></itemizedlist>
</para><para><heading level="3">setDoubleStrike($on)</heading>
</para><para>Turn double-strike mode on/off.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>boolean $on</computeroutput>: true for double strike, false for no double strike.</para></listitem></itemizedlist>
</para><para><heading level="3">setEmphasis($on)</heading>
</para><para>Turn emphasized mode on/off.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>boolean $on</computeroutput>: true for emphasis, false for no emphasis.</para></listitem></itemizedlist>
</para><para><heading level="3">setFont($font)</heading>
</para><para>Select font. Most printers have two fonts (Fonts A and B), and some have a third (Font C).</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $font</computeroutput>: The font to use. Must be either <computeroutput>Printer::FONT_A</computeroutput>, <computeroutput>Printer::FONT_B</computeroutput>, or <computeroutput>Printer::FONT_C</computeroutput>.</para></listitem></itemizedlist>
</para><para><heading level="3">setJustification($justification)</heading>
</para><para>Select justification.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $justification</computeroutput>: One of <computeroutput>Printer::JUSTIFY_LEFT</computeroutput>, <computeroutput>Printer::JUSTIFY_CENTER</computeroutput>, or <computeroutput>Printer::JUSTIFY_RIGHT</computeroutput>.</para></listitem></itemizedlist>
</para><para><heading level="3">setLineSpacing($height)</heading>
</para><para>Set the height of the line.</para><para>Some printers will allow you to overlap lines with a smaller line feed.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $height</computeroutput>: The height of each line, in dots. If not set, the printer will reset to its default line spacing.</para></listitem></itemizedlist>
</para><para><heading level="3">setPrintLeftMargin($margin)</heading>
</para><para>Set print area left margin. Reset to default with <computeroutput>Printer::initialize()</computeroutput>.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $margin</computeroutput>: The left margin to set on to the print area, in dots.</para></listitem></itemizedlist>
</para><para><heading level="3">setPrintWidth($width)</heading>
</para><para>Set print area width. This can be used to add a right margin to the print area. Reset to default with <computeroutput>Printer::initialize()</computeroutput>.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $width</computeroutput>: The width of the page print area, in dots.</para></listitem></itemizedlist>
</para><para><heading level="3">setReverseColors($on)</heading>
</para><para>Set black/white reverse mode on or off. In this mode, text is printed white on a black background.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>boolean $on</computeroutput>: True to enable, false to disable.</para></listitem></itemizedlist>
</para><para><heading level="3">setTextSize($widthMultiplier, $heightMultiplier)</heading>
</para><para>Set the size of text, as a multiple of the normal size.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $widthMultiplier</computeroutput>: Multiple of the regular height to use (range 1 - 8).</para></listitem><listitem><para><computeroutput>int $heightMultiplier</computeroutput>: Multiple of the regular height to use (range 1 - 8).</para></listitem></itemizedlist>
</para><para><heading level="3">setUnderline($underline)</heading>
</para><para>Set underline for printed text.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>int $underline</computeroutput>: Either <computeroutput>true</computeroutput>/<computeroutput>false</computeroutput>, or one of <computeroutput>Printer::UNDERLINE_NONE</computeroutput>, <computeroutput>Printer::UNDERLINE_SINGLE</computeroutput> or <computeroutput>Printer::UNDERLINE_DOUBLE</computeroutput>. Defaults to <computeroutput>Printer::UNDERLINE_SINGLE</computeroutput>.</para></listitem></itemizedlist>
</para><para><heading level="3">text($str)</heading>
</para><para>Add text to the buffer. Text should either be followed by a line-break, or <computeroutput>feed()</computeroutput> should be called after this.</para><para>Parameters:</para><para><itemizedlist>
<listitem><para><computeroutput>string $str</computeroutput>: The string to print.</para></listitem></itemizedlist>
</para><para><heading level="1">Further notes</heading>
</para><para>Posts I&apos;ve written up for people who are learning how to use receipt printers:</para><para><itemizedlist>
<listitem><para><ulink url="https://mike42.me/blog/what-is-escpos-and-how-do-i-use-it">What is ESC/POS, and how do I use it?</ulink>, which documents the output of <computeroutput>example/demo.php</computeroutput>.</para></listitem><listitem><para><ulink url="https://mike42.me/blog/2014-20-26-setting-up-an-epson-receipt-printer">Setting up an Epson receipt printer</ulink></para></listitem><listitem><para><ulink url="https://mike42.me/blog/2015-03-getting-a-usb-receipt-printer-working-on-linux">Getting a USB receipt printer working on Linux</ulink></para></listitem></itemizedlist>
</para><para><heading level="1">Development</heading>
</para><para>This code is MIT licensed, and you are encouraged to contribute any modifications back to the project.</para><para>For development, it&apos;s suggested that you load <computeroutput>imagick</computeroutput>, <computeroutput>gd</computeroutput> and <computeroutput>Xdebug</computeroutput> PHP exensions, and install <computeroutput>composer</computeroutput>.</para><para>The tests are executed on <ulink url="https://travis-ci.org/mike42/escpos-php">Travis CI</ulink> over PHP 5.4, 5.5, 5.6, 7.0, 7.1 and 7.2, plus the latest LTS version of HHVM, 3.21. Older versions of PHP are not supported in current releases.</para><para>Fetch a copy of this code and load dependencies with composer: <verbatim>git clone https://github.com/mike42/escpos-php
cd escpos-php/
composer install
</verbatim></para><para>Execute unit tests via <computeroutput>phpunit</computeroutput>: <verbatim>php vendor/bin/phpunit --coverage-text
</verbatim></para><para>This project uses the PSR-2 standard, which can be checked via <ulink url="https://github.com/squizlabs/PHP_CodeSniffer">PHP_CodeSniffer</ulink>: <verbatim>php vendor/bin/phpcs --standard=psr2 src/ -n
</verbatim></para><para>The developer docs are build with <ulink url="https://github.com/doxygen/doxygen">doxygen</ulink>. Re-build them to check for documentation warnings: <verbatim>make -C doc clean &amp;&amp; make -C doc
</verbatim></para><para>Pull requests and bug reports welcome. </para>    </detaileddescription>
  </compounddef>
</doxygen>
