PHP Classes

PHP Print EPL: Print labels to Zebra printers using EPL commands

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 65%Total: 909 All time: 3,906 This week: 61Up
Version License PHP version Categories
zprinter 1.0.1MIT/X Consortium ...5.6PHP 5, Graphics, Printing
Description 

Author

This class can print labels to Zebra printers using EPL commands.

It can compose labels to print with label text and barcode information and generates a PRN file using EPL commands.

The class can send the PRN file to a Zebra printer with a given printer host name.

It can also configure the number of label copies to print.

Innovation Award
PHP Programming Innovation award nominee
March 2016
Number 13


Prize: One downloadable copy of PhpED Professional
There some types of printers that are dedicated to print labels.

This class can print barcodes in labels supported by Zebra printers.

Manuel Lemos
Picture of Thiago Abrantes
  Performance   Level  
Name: Thiago Abrantes <contact>
Classes: 3 packages by
Country: Brazil Brazil
Age: 39
All time rank: 2037130 in Brazil Brazil
Week rank: 215 Up19 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php

include("classZebra.php");

$hostPrinter = "\\computername\sharedprintername";
$speedPrinter = 4;
$darknessPrint = 2;
$labelSize = array(300,10);
$referencePoint = array(223,15);

$z = new ZebraPrinter($hostPrinter, $speedPrinter, $darknessPrint, $labelSize, $referencePoint);

$z->setBarcode(1, 344, 80, "ContentBarCode"); #1 -> cod128
$z->writeLabel("TestLabel",344,30,4);
$z->setBarcode(1, 344, 230, "ContentBarCode"); #1 -> cod128
$z->writeLabel("TestLabel",344,180,4);
$z->setLabelCopies(1);
$z->print2zebra();




?>


Details

PHP2EPL

PHP2ELP is a short class that creates an EPL command and sends it to a remote shared Zebra© Printer

Step By Step

1) Creating the object

Start by creating an ZebraPrinter object and setting the Host Printer, speed, darkness (or tempeture), the label size and reference point. The label size is an array composed by the Label height followed by the gap width.

$hostPrinter = "\\computername\sharedprintername";
$speedPrinter = 4;
$darknessPrint = 2;
$labelSize = array(240,024);
$referencePoint = array(215,15);
$z = new ZebraPrinter($hostPrinter, $speedPrinter, $darknessPrint, $labelSize,$referencePoint);

2) Calling the methods

$z->writeLabel($l,$x,$y,$f);

Write the content l at the (x, y) position with f font size. Be careful, the coordinates are expressed in "dots".

$z->setBarcode($code, $x, $y, $content)

Set the barcode codification (see the [manual][manual] at page 53), (x, y) possition and barcode value. Again, the coordinates are expressed in "dots".

$z->setLabelCopies($n);

After the label config is done, call this method to set the number of copies.

$z->print2zebra();

This method generates the a temp *.prn with an EPL command and sends it to the remote Zebra© printer.

Observations

- This code was tested in a Windows environment. - [PLEASE CHECK THE REFERENCE MANUAL][manual] [manual]:https://www.zebra.com/content/dam/zebra/manuals/en-us/printer/epl2-pm-en.pdf

###

The MIT License (MIT)

Copyright (c) 2016 Thiago Abrantes de C. Souza, <abrantes.souza@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    
      

- This code was tested in a Windows environment. - [PLEASE CHECK THE REFERENCE MANUAL][manual] [manual]:https://www.zebra.com/content/dam/zebra/manuals/en-us/printer/epl2-pm-en.pdf


  Files folder image Files (3)  
File Role Description
Plain text file classZebra.php Class Class of application
Plain text file README.md Doc. Readme File
Plain text file testeZebra.php Example Test File.

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:909
This week:0
All time:3,906
This week:61Up
User Ratings User Comments (1)
 All time
Utility:83%StarStarStarStarStar
Consistency:75%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:91%StarStarStarStarStar
Tests:-
Videos:-
Overall:65%StarStarStarStar
Rank:586