Giter Club home page Giter Club logo

weez-zpl's Introduction

Weez-ZPL

Inspired by w3blogfr/zebra-zpl

This library will help you to quickly generate ZPL code for your Zebra printer.

Library support only most commons ZPL commons (Text, Code bar 39)

For the moment, library was tested on Zebra 300 dpi with native font zebra-0. I

But you can insert natif zpl at all times.

You can also fork this project and share code if you make this library better.

Getting started

Clone the repository and install dependencies:

$ git clone https://github.com/teddy-dubal/weez-zpl.git
$ cd weez-zpl/docker
$ docker-compose up
$ docker exec -it docker_appzpl_1 bash
$ su application
$ composer install
$ php test.php
$faker      = Factory::create();
$fakerImage = $faker->image(null, 150, 150, 'transport', true);
//Init Label
$zebraLabel = new ZebraLabel(912, 912);
$zebraLabel->setDefaultZebraFont(new ZebraFont(ZebraFont::ZEBRA_ZERO));
//Add Text element
$zebraLabel->addElement(new ZebraText(10, 84, "Product:", 14));
$zebraLabel->addElement(new ZebraText(395, 84, "Camera", 14));

$zebraLabel->addElement(new ZebraGraficBox(10, 100, 800, 5));

$zebraLabel->addElement(new ZebraText(10, 161, "CA201212AA", 14));

//Add Code Bar 39
$zebraLabel->addElement(new ZebraBarCode39(10, 297, "CA201212AA", 118, 2, 2));

$zebraLabel->addElement(new ZebraText(10, 365, "Qté:", 11));
$zebraLabel->addElement(new ZebraText(180, 365, "3", 11));
$zebraLabel->addElement(new ZebraText(317, 365, "QA", 11));

$zebraLabel->addElement(new ZebraText(10, 520, "Ref log:", 11));
$zebraLabel->addElement(new ZebraText(180, 520, "0035", 11));
$zebraLabel->addElement(new ZebraText(10, 596, "Ref client:", 11));
$zebraLabel->addElement(new ZebraText(180, 599, "1234", 11));
//Add Image from Url
$zebraLabel->addElement(new ZebraImage(350, 850, $fakerImage));
//Add Qr Code
$zebraLabel->addElement(new ZebraQrCode(350, 297, 'test'));

echo $zebraLabel->getZplCode();

Native code

If you need to customise your label

$zebraLabel.addElement(new ZebraNativeZpl("^KD0\n"));
/*
You can also use usefull fonction ZplUtils.zplCommand to generate a zpl command (with many variables)
*/
ZplUtils::zplCommand("A", ["0", "R"]); //will return ^A,0,R

Zpl Viewver

http://labelary.com/viewer.html

Written with StackEdit.

weez-zpl's People

Contributors

chriskonnertz avatar teddy-dubal 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

Watchers

 avatar  avatar

weez-zpl's Issues

ZEBRA_ZERO not a string

Why is ZEBRA_ZERO defined as 0 (int) and not '0' (string)?

Afterwards you expect the letter-parameter as string:

/**
*

  • @param string $letter
    */
    public function __construct($letter) {
    $this->letter = $letter;
    }

Namespaces in Annotations

Hello,

great library!

By using it I recognized that class names in annotation seem to miss namespaces. For example: https://github.com/teddy-dubal/weez-zpl/blob/master/src/Weez/Zpl/Model/ZebraLabel.php#L85

    /**
     * Use to define a default Zebra font on the label
     *
     * @param ZebraFont $defaultZebraFont
     * @return self
     */
    public function setDefaultZebraFont($defaultZebraFont)

The defaultZebraFont parameter is of type ZebraFont. Since no namespace is provided, the namespace is the same as of the "surrounding" class, Weez\Zpl\Model\ZebraLabel in this case. Therefore the assumed namespace is Weez\Zpl\Model\, which means the full qualified name of the class is assumed to be Weez\Zpl\Model\ZebraFont. Which is wrong, no such class with this name exists, actually it should be Weez\Zpl\Constant\ZebraFont.

I used to do the same: only using (short) class names in annotations and not importing their namespaces. However, my IDE (PhpStorm) is capable of reading these annotations, but it cannot guess the namespace, so it is displaying errors...

Therefore it would be awesome to have correct class names / namespaces in the annotations!

Can't add image to zpl

Hi,

I can't put image on zpl label cause when i try to add image i got this error:
Class 'Zebra\Zpl\Image' not found in path.../ZPLBuilder/Model/Element/ZebraImage.php on line 29
My server is running php 5.5.38
i don't install it with docker but i download the file and put to server.
I already try like example but i got this error:
Class 'Factory' not found

How i can resolve?

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.