BarCode

Overview #

The Barcode package allows you to create various type of barcodes and qrcodes in multiple format like jpg, png and svg.

Installation #

By downloading .zip file #

  1. Download zip file from My Licenses
  2. Unzip
  3. Copy the folder barcode into koolreport folder, it will look like below:
koolreport
├── core
├── barcode

By composer #

If you have purchased the package then you can follow these steps to install

  1. Login to koolreport.com
  2. Go to My Licenses
  3. Click Get Token For Composer button
  4. Copy the text and save to file auth.json next to composer.json
  5. Add the repositories to composer.json like below
  6. Run composer update to install package

composer.json

{
    "repositories":[
      {"type":"composer","url":"https://repo.koolreport.com"}
    ],
    "require":{
        "koolreport/barcode":"*",
        ...
    }
}

Your auth.json will look like this:

{
    "http-basic": {
        "repo.koolreport.com": {
            "username": "your@email.com",
            "password": "your-secret-token"
        }
    }
}

Note: Please add your auth.json to .gitignore as it contains your secret login information.

Quickstart #

In your view, you could use the BarCode and QRCode widgets like following:

<?php
  //MyReport.view.php
  use \koolreport\barcode\BarCode;
  use \koolreport\barcode\QRCode;
?>
...
  <?php
  BarCode::create(array(
    "format" => "html", //"svg", "png", "jpg"
    "value" => "081231723897",
    "type" => "TYPE_CODE_128",
    "widthFactor" => 2,
    "height" => 30,
    "color" => "black", //"{{color string}}" for html and svg, array(R, G, B) for jpg and png
  ));
  ?>

...

  <?php
  QRCode::create(array(
    "format" => "svg", //"png", "jpg"
    "value" => "Test QRCode",
    "size" => 150,
    "foregroundColor" => array(0, 0, 0),
    "backgroundColor" => array(255, 255, 255),
  ));
  ?>

BarCode #

Properties #

nametypedefaultdescription
formatstring"jpg"This property defines the output format of barcodes. We have 4 formats: html (using divs and background color), svg (vector image), jpg and png.
valuestring""This is the value of barcode
typestring"TYPE_CODE_128"This property is for various types of barcode. List of support barcode type is below.
widthFactornumber"2px"This is the width of each bar in pixel
heightnumber30This set the height of barcodes.
colorstring/arrayA color string for html and svg formats; an array of (r, g, b) values for jpg and png formats.

List of types #

Supported types of BarCodes
TYPE_CODE_39TYPE_CODE_39_CHECKSUMTYPE_CODE_39_CHECKSUM
TYPE_CODE_39ETYPE_CODE_39E_CHECKSUMTYPE_CODE_93
TYPE_STANDARD_2_5TYPE_STANDARD_2_5_CHECKSUMTYPE_INTERLEAVED_2_5
TYPE_INTERLEAVED_2_5_CHECKSUMTYPE_CODE_128TYPE_CODE_128_A
TYPE_CODE_128_BTYPE_CODE_128_CTYPE_EAN_2
TYPE_EAN_5TYPE_EAN_8TYPE_EAN_13
TYPE_UPC_ATYPE_UPC_ETYPE_MSI
TYPE_MSI_CHECKSUMTYPE_POSTNETTYPE_PLANET
TYPE_RMS4CCTYPE_KIXTYPE_IMB
TYPE_CODABARTYPE_CODE_11TYPE_PHARMA_CODE
TYPE_PHARMA_CODE_TWO_TRACKS

QRCode #

Properties #

nametypedefaultdescription
formatstring"jpg"This property defines the output format of qrcodes. We have 3 formats: svg, jpg and png.
valuestring""This is the value of qrcode.
sizenumber150Set the size in px of qrcodes.
foregroundColorarrayarray(0,0,0)An array of (r, g, b) values for the foreground color of qrcodes.
backgroundColorarrayarray(255, 255, 255)An array of (r, g, b) values for the background color of qrcodes.

Get started with KoolReport

KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.