<?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="md_FAQ" kind="page">
    <compoundname>md_FAQ</compoundname>
    <title>Frequently Asked Questions (FAQ)</title>
    <detaileddescription>
<para><heading level="2">Can I print to File Format X with this?</heading>
</para><para>If you are trying to generate XPS, PDF or DOCX or HTML files from PHP, then you are most likely in the wrong place.</para><para>The purpose of this driver it to generate binary ESC/POS code, which is understood by many embedded thermal receipt and impact printers.</para><para><heading level="2">I have Printer X. Can I use this driver?</heading>
</para><para>If the printer understands ESC/POS, and you know how to get raw binary data to it, then yes. Otherwise, no.</para><para>The <ulink url="https://github.com/mike42/escpos-php/blob/development/README.md#printers">list of printers that are known to work</ulink> is crowd-sourced. We appreciate it when developers try out the driver, then <ulink url="https://github.com/mike42/escpos-php/issues/new">file information on the bug tracker</ulink> with some information about which features worked on their model of printer.</para><para>To see how well your printer works, first check that it supports ESC/POS, then begin by attempting to send the text &quot;Hello World&quot; to your printer on the command-line, from the computer that will run PHP.</para><para>Once you solve this, <ulink url="https://github.com/mike42/escpos-php/blob/development/README.md#basic-usage">try to do the same from PHP</ulink> using the default profile. Further details are in the https://github.com/mike42/escpos-php/blob/development/README.md &quot;README&quot; file.</para><para><heading level="2">Can you add support for Printer X?</heading>
</para><para>Features vary between printers, so we collaborate on an ESC/POS printer compatibility database to collect known differences: <ulink url="https://github.com/receipt-print-hq/escpos-printer-db">receipt-print-hq/escpos-printer-db</ulink>.</para><para>If you encounter garbage output when you try to print images or special characters, then please submit a test page and a link to vendor documentation to the <computeroutput>escpos-printer-db</computeroutput> project, so that support can be improved for future versions.</para><para><heading level="2">I have a printer that does not understand ESC/POS. Can I use this driver?</heading>
</para><para>No. The purpose of this driver it to generate binary ESC/POS code. If your printer doesn&apos;t understand that, then this code wont be much use to you.</para><para>Some printers do have an emulation mode for ESC/POS. The vendor docs will tell if this is the case, and how to enable it.</para><para><heading level="2">Why do I get this error when I try to print?</heading>
</para><para>Start by testing that you can send text to your printer outside of escpos-php. The examples linked to in the README are commented with some commands to get you started.</para><para>Generally, initial setup problems seem to have one of these causes:</para><para><orderedlist>
<listitem><para>You are writing to the wrong place. Writing to <computeroutput>LPT1</computeroutput> does not output to parallel port on Linux, and <computeroutput>/dev/ttyS0</computeroutput> is not a serial printer on Windows.</para></listitem><listitem><para>The printer has not been set up to accept printing the way you expect. This means permissions on Linux, network printers being configured, and shared printers having user accounts and firewalls set up correctly on the print server.</para></listitem><listitem><para>Your printer actually doesn&apos;t work (rare but possible).</para></listitem></orderedlist>
</para><para>To be clear, these are not escpos-php issues: No amount of PHP code can set up your printer for you. Instead, the driver relies on developers determining how their setup is going to work before using a connector to transport data to their printer.</para><para>Once you have a working command to send text to your printer (from the PHP server), you are ready to use escpos-php. You can try to use a PrintConnector now, based on your operating system and printer interface. A table is located in the README to help you select the right one.</para><para>The connectors are-</para><para><itemizedlist>
<listitem><para><computeroutput>FilePrintConnector</computeroutput> and <computeroutput>NetworkPrintConnector</computeroutput> directly use files or network sockets.</para></listitem><listitem><para><computeroutput>WindowsPrintConnector</computeroutput> and <computeroutput>CupsPrintConnector</computeroutput> tie in with Windows and Unix system printing.</para></listitem><listitem><para><computeroutput>DummyPrintConnector</computeroutput> does not connect to a real printer, and can be used to save ESC/POS receipts to a database, for example.</para></listitem></itemizedlist>
</para><para>At this point, you might find that the way you would like to print is not supported by escpos-php. You can post your printing command as a feature request on the issue tracker.</para><para>Lastly, you may run in to the final common trap:</para><para><orderedlist>
<listitem><para>Your PHP is not running with the same sort of permissions as your login account. Again, no amount of PHP code can fix this. For example, on LAMP, your <computeroutput>www-data</computeroutput> user needs to be in the <computeroutput>lp</computeroutput> group, while on WAMP, <computeroutput>Local Service</computeroutput> account may run in to problems. SELinux and firewalls are also worth a look.</para></listitem></orderedlist>
</para><para>When printing fails, you can expect a PHP Exception that explains what went wrong. They are all clues:</para><para><itemizedlist>
<listitem><para><computeroutput>Warning: copy(\\pc\printer): failed to open stream: Permission denied</computeroutput></para></listitem><listitem><para><computeroutput>/dev/usb/lp0: Permission denied</computeroutput></para></listitem><listitem><para><computeroutput>User name or password is incorrect</computeroutput></para></listitem></itemizedlist>
</para><para>Ensure that while you are developing, you configure PHP to show error messages, so that you can see these problems.</para><para>Please file a bug if you think that there is a specific situation which escpos-php could provide better error messages for.</para><para><heading level="2">Can I print over the network?</heading>
</para><para>Certainly, as long as your printer is available over the network.</para><para><itemizedlist>
<listitem><para><computeroutput>NetworkPrintConnector</computeroutput> will speak directly to an Ethernet-connected printer on port 9100.</para></listitem></itemizedlist>
</para><para>For USB or Serial printers, you need to install the printer on a computer and then share it, so that it becomes network-accessible.</para><para><itemizedlist>
<listitem><para><computeroutput>WindowsPrintConnector</computeroutput> will connect to Windows shared printers from Windows or Linux (Linux users will need Samba).</para></listitem><listitem><para><computeroutput>CupsPrintConnector</computeroutput> will connect to CUPS-shared printers from Linux or Mac.</para></listitem></itemizedlist>
</para><para>Always start by testing your shared printer setup outside of escpos-php. The examples linked to in the README are commented with some example commands to get you started. Typically, networks, firewalls and permissions need to be set up.</para><para>Once you have a working command to send text to your printer (from the PHP server), you are ready to use escpos-php.</para><para>If you have any issues at this stage, please ask on the issue tracker, and include the commands that you used to verify your setup.</para><para><heading level="2">Can I print from my server on the Internet?</heading>
</para><para>Since PHP is a server-side language, escpos-php is a server-side print library. The driver is able to transport data between a server and a printer in a few different ways, all of them server-side. For example, you may print to a USB printer <emphasis>connected to the server running PHP</emphasis>, or an Ethernet printer <emphasis>on a network accessible to the server</emphasis>.</para><para>Many developers dream of having an application that is hosted on the public Internet, with POS terminals accessing it, and printing via a web browser. Because the webserver cannot see the printer in this sort of setup, a server-side print driver is not much use.</para><para>Because of this, there are no cut-and-paste recipes available, but here are two top-level approaches you could take:</para><para><orderedlist>
<listitem><para>Architect your application so that the server can see your printer</para></listitem><listitem><para>Use an application which runs client-side to deliver print data instead</para></listitem></orderedlist>
</para><para><heading level="3">Option 1: Allow the server to print</heading>
</para><para>Server-side printing is viable if the server can get to the printer. Here are some ways it could work:</para><para><itemizedlist>
<listitem><para>Run your server on the LAN instead, and read the section above about printing over the network</para></listitem><listitem><para>Set up a VPN so that your cloud-hosted server can also access the LAN</para></listitem><listitem><para>Expose the printer via some other secure tunnel to the server, via SSH or TLS</para></listitem></itemizedlist>
</para><para>Please do your own research to determine how these may apply to your setup- the escpos-php issue tracker is not a place where you should be requesting network support.</para><para><heading level="3">Option 2: Use client software to print</heading>
</para><para>If you aren&apos;t able to set up some network infrastructure to implement the above, then you cannot use a server-side print driver.</para><para>Here are some browser-based printing tools which you may like to consider instead.</para><para><itemizedlist>
<listitem><para>Use system printing with a vendor driver, and some good <computeroutput>@media print</computeroutput> CSS</para></listitem><listitem><para><ulink url="https://github.com/receipt-print-hq/chrome-raw-print">Chrome Raw Print</ulink> app</para></listitem><listitem><para><ulink url="https://qz.io/">qz</ulink></para></listitem><listitem><para><ulink url="https://reference.epson-biz.com/modules/ref_epos_device_js_en/index.php?content_id=139">ePOS-Device SDK for JavaScript</ulink>. Requires network interface card that supports ePOS (UB-E04/R04)</para></listitem></itemizedlist>
</para><para>Please direct queries about client-side printing products to the appropriate project.</para><para><heading level="2">Why is image printing slow?</heading>
</para><para>Three things tend to slow down the image processing:</para><para><orderedlist>
<listitem><para>Slow PHP code</para></listitem><listitem><para>Data link</para></listitem><listitem><para>The printer itself</para></listitem></orderedlist>
</para><para>First, ensure you have the Imagick plugin loaded. The driver will avoid a slower image processing implementation once you&apos;ve got it.</para><para>Next, connect over a faster interface. Serial printers have a low bit-rate, and the printer spends a lot of time waiting for data. If you have USB or Ethernet, then use it (note: storing graphics to the printer memory is not currently implemented).</para><para>Lastly, the printer will go faster if you use less pixels. Since images are two-dimensional, scaling down by 50% removes 75% of the pixels. The driver can then print at a half the density, so that your lower resolution image appears the same size when printed.</para><para><heading level="2">How can I get the status of the printer?</heading>
</para><para>This feature is not implemented, but a solution for some Epson printers is planned.</para><para>Only <computeroutput>FilePrintConnector</computeroutput> or <computeroutput>NetworkPrintConnector</computeroutput> will support reading from the printer, ensure that you migrate to those if you would like these features.</para><para><heading level="2">How do I produce this complex layout?</heading>
</para><para>ESC/POS &quot;page mode&quot; is not currently supported, which would allow some printers to render some more complex layouts natively</para><para>Since the output is raster anyway, it is suggested that you render your output to an image and print that instead. The driver supports PDF printing via Imagick, and an example that uses <computeroutput>wkhtmltoimage</computeroutput> is available in the repository. </para>    </detaileddescription>
  </compounddef>
</doxygen>
