GithubHelp home page GithubHelp logo

tecnickcom / tc-lib-barcode Goto Github PK

View Code? Open in Web Editor NEW
263.0 21.0 90.0 924 KB

PHP library to generate linear and bidimensional barcodes

License: Other

Makefile 1.24% PHP 98.76%
php barcode c93 c128 ean13 upca upce msi postnet planet

tc-lib-barcode's Introduction

tc-lib-barcode

PHP barcode library

Latest Stable Version Build Coverage License Downloads

Donate via PayPal Please consider supporting this project by making a donation via PayPal

Description

This library includes utility PHP classes to generate linear and bidimensional barcodes:

  • C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9
  • C39+ : CODE 39 with checksum
  • C39E : CODE 39 EXTENDED
  • C39E+ : CODE 39 EXTENDED + CHECKSUM
  • C93 : CODE 93 - USS-93
  • S25 : Standard 2 of 5
  • S25+ : Standard 2 of 5 + CHECKSUM
  • I25 : Interleaved 2 of 5
  • I25+ : Interleaved 2 of 5 + CHECKSUM
  • C128 : CODE 128
  • C128A : CODE 128 A
  • C128B : CODE 128 B
  • C128C : CODE 128 C
  • EAN2 : 2-Digits UPC-Based Extension
  • EAN5 : 5-Digits UPC-Based Extension
  • EAN8 : EAN 8
  • EAN13 : EAN 13
  • UPCA : UPC-A
  • UPCE : UPC-E
  • MSI : MSI (Variation of Plessey code)
  • MSI+ : MSI + CHECKSUM (modulo 11)
  • POSTNET : POSTNET
  • PLANET : PLANET
  • RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
  • KIX : KIX (Klant index - Customer index)
  • IMB : IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
  • IMBPRE : IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200- pre-processed
  • CODABAR : CODABAR
  • CODE11 : CODE 11
  • PHARMA : PHARMACODE
  • PHARMA2T : PHARMACODE TWO-TRACKS
  • AZTEC : AZTEC Code (ISO/IEC 24778:2008)
  • DATAMATRIX : DATAMATRIX (ISO/IEC 16022)
  • PDF417 : PDF417 (ISO/IEC 15438:2006)
  • QRCODE : QR-CODE
  • RAW : 2D RAW MODE comma-separated rows
  • RAW2 : 2D RAW MODE rows enclosed in square parentheses

Output Formats

  • PNG Image
  • SVG Image
  • HTML DIV
  • Unicode String
  • Binary String

The initial source code has been derived from TCPDF.

Getting started

First, you need to install all development dependencies using Composer:

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer

This project include a Makefile that allows you to test and build the project with simple commands. To see all available options:

make help

To install all the development dependencies:

make deps

Running all tests

Before committing the code, please check if it passes all tests using

make qa

All artifacts are generated in the target directory.

Examples

Examples are located in the example directory.

Start a development server (requires PHP 8.0+) using the command:

make server

and point your browser to http://localhost:8000/index.php

Simple Code Example

Please check example/index.php for a full example.

// instantiate the barcode class
$barcode = new \Com\Tecnick\Barcode\Barcode();

// generate a barcode
$bobj = $barcode->getBarcodeObj(
    'QRCODE,H',                     // barcode type and additional comma-separated parameters
    'https://tecnick.com',          // data string to encode
    -4,                             // bar width (use absolute or negative value as multiplication factor)
    -4,                             // bar height (use absolute or negative value as multiplication factor)
    'black',                        // foreground color
    array(-2, -2, -2, -2)           // padding (use absolute or negative values as multiplication factors)
    )->setBackgroundColor('white'); // background color

// output the barcode as HTML div (see other output formats in the documentation and examples)
echo $bobj->getHtmlDiv();

Installation

Create a composer.json in your projects root-directory:

{
    "require": {
        "tecnickcom/tc-lib-barcode": "^2.0"
    }
}

Or add to an existing project with:

composer require tecnickcom/tc-lib-barcode ^2.0

Packaging

This library is mainly intended to be used and included in other PHP projects using Composer. However, since some production environments dictates the installation of any application as RPM or DEB packages, this library includes make targets for building these packages (make rpm and make deb). The packages are generated under the target directory.

When this library is installed using an RPM or DEB package, you can use it your code by including the autoloader:

require_once ('/usr/share/php/Com/Tecnick/Barcode/autoload.php');

Developer(s) Contact

tc-lib-barcode's People

Contributors

alex-bukach avatar caffe1neadd1ct avatar cedric-anne avatar fooman avatar maff avatar nicolaasuni avatar remicollet avatar ulrich-berkmueller avatar valiodotch avatar xclynaj 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tc-lib-barcode's Issues

Height/width flipped in example

Hi,

Thanks for this lib!

It seems that the height and width are flipped around in the //comment in the example in the readme.

Decoding of barcode image

Hello.

Could you clarify me, does your library allow to decode barcode from image into string or number value ?

That is, I call a function, send it an image with barcode and the function returns me the decoded value.

Thanks in advance for your response.

Can't get the right IMB output

As described here: http://stackoverflow.com/questions/5089511/how-to-generate-intelligent-mail%C2%AE-barcode-onecode-via-php

I'm having trouble with this library. It doesn't generate the same IMB as stamps.com or as this online generator: bobcodes.weebly.com/imb.html or as this online generator: http://generator.onbarcode.com/online-intelligent-mail-onecode-barcode-generator.aspx

Code used:
$bobj = $barcode->getBarcodeObj('IMB', $imbBarcode, -4, -11, 'black', array(2, 2, 2, 2));
$newBarcode = $bobj->getGd();
imagecopy($finalImage, $newBarcode, 975, 390, 0,0, 665, 65);

Here's a comparison. The upper bar code is what tc-lib generates. The lower bar code is what stamps.com and those two other links I gave generates. These are for 0004089956453869648007724.

Many thanks!
imb output comparison 2016-05-28 00-57-03

Visibility Fatal with Init

Following your README example, I'm seeing this error:

Fatal error: Call to protected Com\Tecnick\Barcode\Type\Square\QrCode\Init::init() from context 'Com\Tecnick\Barcode\Type\Square\QrCode' in vendor/tecnickcom/tc-lib-barcode/src/Type/Square/QrCode.php on line 217

Stacktrace:

Com\Tecnick\Barcode\Barcode->getBarcodeObj(   )                | ..\index.php:32
Com\Tecnick\Barcode\Type->__construct(   )                     | ..\Barcode.php:122
Com\Tecnick\Barcode\Type\Square\QrCode->setBars(   )           | ..\Type.php:171
Com\Tecnick\Barcode\Type\Square\QrCode->encodeString(   )      | ..\QrCode.php:179

v1.15.20 installed via Composer on Windows 10 using PHP 5.3.2.

Aztec codes

Aztec codes ?

Can this excellent package be further enhanced to produce 2D Aztec codes ?

[Discussion] GS1 datamatrix support

I'm looking to implement GS1 support in datamatrix barcodes, which requires adding handling of FNC1, so I'm looking for a brief discussion on what would be the best way to go about this.

From GS1 DataMatrix - An Introduction and Implementation Guideline: "The GS1 DataMatrix is formed by adding FNC1 codeword in the first position of Data Matrix ECC 200 version." (page 8) This document also includes a table with codewords, which lists value 232 for FNC1. (page 50)

It's not possible to use the current Datamatrix to add FNC1, as constructing a barcode with chr(232), will encapsulate the char before adding it to the barcode.

My initial thought was to add a check to the datamatrix barcode type for the first char, but that could create issues for users who want to start their barcode with chr(232) as data instead of FNC1.

Would adding a new class for GS1-datamatrix be a better solution? I guess that would only require a small wrapper, that inherits the current datamatrix class and adds the check.

Right way to generate a GS1-128 barcode

This is just a question. I'm trying to generate this codebar:

image

Is this the right way to do it ?

$gs1Number = '7709998943619';
$paymentNumber = '0118000008';
$amountToPay = '0030000000';
$maxPayDate = '20180626';
$data = "415{$gs1Number}8020{$paymentNumber}3900{$amountToPay}96{$maxPayDate}";
$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj('C128C', $data, 450, 70, 'black', array(0, 0, 0, 0));

Missing Dependency

There appears to be a missing dependency. When first running the tests I get 26 errors. After installing bcmath, all issues are resolved.

apt install php-bcmath 

Example error:

./vendor/bin/phpunit test
PHPUnit 5.7.9 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.0.13-0ubuntu0.16.04.1
Configuration: /home/jalandis/workspace/tc-lib-barcode/phpunit.xml.dist
Error:         No code coverage driver is available

.......................................E.......................  63 / 183 ( 34%)
................................................E.EEEEEE..EEEEE 126 / 183 ( 68%)
EEEEEEEEEEEEE............................................       183 / 183 (100%)

Time: 6.27 seconds, Memory: 18.00MB

There were 26 errors:

1) Test\Linear\ImbTest::testGetGrid
Error: Call to undefined function Com\Tecnick\Barcode\Type\Linear\bcmul()

tc-lib-barcode/src/Type/Linear/Imb.php:251
tc-lib-barcode/src/Type/Linear/Imb.php:312
tc-lib-barcode/src/Type.php:171
tc-lib-barcode/src/Barcode.php:122
tc-lib-barcode/test/Linear/ImbTest.php:41

can i use it without composer?

i want to setup barcode feature on an old device with a old version of PHP ( like 5.6.x ), and for some reasons i can not upgrade or install composer.

it's there any way to use without composer autoload, or any other project as replacement.

Encoding of datamatrix

Hello,
default encoding (ASCII) seems to be hard coded in method getHighLevelEncoding : could the params be used to set the desired encoding ?
I managed to fork and patch but i'm not proud of that (my case is to use C40 as default encoding)
Thanks for your help if it's possible.

UPC-E incorrect

I have generate UPC-E for 06141939 code in three different variations which is all valid, but scanner doesn't recognize it. Valid barcode should begin with two short bars, but generated has three.:

614193
image

0614193
image

06141939
image

valid barcode generated on https://barcode.tec-it.com/en/UPCE?data=04252614:
image

my code:

$svgContent = new Com\Tecnick\Barcode\Barcode()
            ->getBarcodeObj('UPCE', '614193', -8, 480, 'black')
            ->setBackgroundColor('white')
            ->getSvgCode();

EAN13 Numbers

Hello!

First, thank you for the excellent work for with this SDK, works very well.
However, I can't seem to get the numbers to be printed along with the barcode for EAN13?

Is this possible with this library?
Something like this is what I have in mind:
http://prntscr.com/e8y0a1

svg viewBox for IE resizing

https://github.com/tecnickcom/tc-lib-barcode/blob/develop/src/Type.php
line 325

for IE img tag width

$svg = '<?xml version="1.0" standalone="no" ?>'."\n" .'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'."\n" .'<svg width="'.sprintf('%F', ($this->width + $this->padding['L'] + $this->padding['R'])) .'" height="'.sprintf('%F', ($this->height + $this->padding['T'] + $this->padding['B'])).'"' .' version="1.1" xmlns="http://www.w3.org/2000/svg">'."\n" ."\t".'<desc>'.htmlspecialchars($this->code, $hflag, 'UTF-8').'</desc>'."\n" ."\t".'<g id="bars" fill="'.$this->color_obj->getRgbHexColor().'"' .' stroke="none" stroke-width="0" stroke-linecap="square">'."\n";
to

$width = sprintf('%F', ($this->width + $this->padding['L'] + $this->padding['R'])); $height = sprintf('%F', ($this->height + $this->padding['T'] + $this->padding['B'])); $svg = '<?xml version="1.0" standalone="no" ?>'."\n" .'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'."\n" .'<svg width="'.$width .'" height="'.$height.'"' .' viewBox="0 0 '.$width.' '.$height.'"' .' version="1.1" xmlns="http://www.w3.org/2000/svg">'."\n" ."\t".'<desc>'.htmlspecialchars($this->code, $hflag, 'UTF-8').'</desc>'."\n" ."\t".'<g id="bars" fill="'.$this->color_obj->getRgbHexColor().'"' .' stroke="none" stroke-width="0" stroke-linecap="square">'."\n";

thank you.

Add getTable method to obtain table based html

I know that already exists getDiv that provide a easy-to-use html code but there is a case where div cannot be used.
If the library is used to produce HTML for emails it doesn't work. Many email clients are not able to properly display div with padding and borders.
Using a matrix of cells with table tag should works.

What you think about this feature?

Generating wrong code for QRCODE SVG

This is how I am using it to generate SVG code for Barcode
But browser is unable to view it because there is some mistake in generated SVG Code

<?php

$barcode = new \Com\Tecnick\Barcode\Barcode();

// generate a barcode
$bobj = $barcode->getBarcodeObj(
    'QRCODE,H',                     // barcode type and additional comma-separated parameters
    'https://schoolpi.app',         // data string to encode
    -4,                             // bar width (use absolute or negative value as multiplication factor)
    -4,                             // bar height (use absolute or negative value as multiplication factor)
    'black',                        // foreground color
    array(-2, -2, -2, -2)           // padding (use absolute or negative values as multiplication factors)
)->setBackgroundColor('white'); // background color

echo file_put_contents('d.svg', $bobj->getSvgCode());

?>

I found the issue and error is inside this line

<rect x="0" y="0" width="132.000000" height="132.000000" fill="#ffffff" stroke="none" stroke-width="0" stroke-linecap="square""/>

So the generated code should be like this

<rect x="0" y="0" width="132.000000" height="132.000000" fill="#ffffff" stroke="none" stroke-width="0" stroke-linecap="square"/>

The only difference is stroke-linecap="square"" to stroke-linecap="square"

Please fix the issue
Thanks

Æ,æ,Ø,ø,Å,å danish letters in barcode data

Hello,
I'm creating DATA MATRIX barcode, but, when data contain any special chars like danish letters (Æ,æ,Ø,ø,Å,å), created barcode cannot be scanned.

Creating barcode and saving in png file:
$barcode = new Barcode();
$barcodeObj = $barcode->getBarcodeObj('DATAMATRIX', 'Some string with Æ,æ,Ø,ø,Å,å chars', 150, 150);
$barcodeName = $this->upload->getRandomFileName() . '.png';
$path = $this->upload->getPath($barcodeName, false);
$barcode = $barcodeObj->getGd();
imagepng($barcode, $path);

Importing png image in pdf using mPdf lib
$mpdf->Image($path, x, y, w, h);

Output original value below the barcode?

This isn't an issue, just a quick question. Is there any way to include the original value in the output barcode? For example, the original value (code) underneath the bars of a linear barcode?

installation wia composer fails


composer require tecnick.com/tc-lib-barcode

fails with


Using version ^1.4 for tecnick.com/tc-lib-barcode
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - tecnick.com/tc-lib-barcode 1.4.2 requires tecnick.com/tc-lib-color dev-master -> no matching package found.
    - tecnick.com/tc-lib-barcode 1.4.1 requires tecnick.com/tc-lib-color dev-master -> no matching package found.
    - tecnick.com/tc-lib-barcode 1.4.0 requires tecnick.com/tc-lib-color dev-master -> no matching package found.
    - Installation request for tecnick.com/tc-lib-barcode ^1.4 -> satisfiable by tecnick.com/tc-lib-barcode[1.4.0, 1.4.1, 1.4.2].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, deleting ./composer.json.

It fails in similar way when using composer.json example from README.md

EDIFACT encoding doesn't work correctly

Hi. EDIFACT encoding doesn't work correctly:

-=-1-=-2-=-3xyz => -=-1-=-2-=-3^W); \AW[)> 06 03
-=-1-=-2-=-3-xy => -=-1-=-2-=-3xy

<?php require ('vendor/autoload.php'); $barcode = new \Com\Tecnick\Barcode\Barcode(); echo "<style>body{margin: 50}</style>"; echo "<p>-=-1-=-2-=-3xyz</p>"; $bobj = $barcode->getBarcodeObj('DATAMATRIX', '-=-1-=-2-=-3xyz', -4, -4); echo $bobj->getHtmlDiv(); echo "<br /><br /><br />"; echo "<p>-=-1-=-2-=-3-xy</p>"; $bobj = $barcode->getBarcodeObj('DATAMATRIX', '-=-1-=-2-=-3-xy', -4, -4); echo $bobj->getHtmlDiv();

I propose a solution

EAN13 checksum is not public

If you create an EAN13 barcode for a 12 digit code, the checksum will be appended and added to the bars. For example, creating an EAN13 barcode for 123456789012 returns actually this barcode: 1234567890128.
Could you make this final code outside accessible, so it can be printed under the barcode or automatically appended on importing 12 digit codes? Currently it is handled in protected methods and variables.

datamatrix encode issue

just use sample code with following:

// generate a barcode
$bobj = $barcode->getBarcodeObj(
'DATAMATRIX', // barcode type and additional comma-separated parameters
'Schéma', // data string to encode
-4, // bar width (use absolute or negative value as multiplication factor)
-4, // bar height (use absolute or negative value as multiplication factor)
'black', // foreground color
array(-2, -2, -2, -2) // padding (use absolute or negative values as multiplication factors)
)->setBackgroundColor('white'); // background color

datamatrix fail to encode the unicode in base256 correctly, will read out by scanner as Schéma

Code128 C Type Encoding

Having a look at the Code128 barcode specs for Royal Mail / UPU tracking barcode(s), they appear to generate a slightly different barcode to this library due to the Type C switch part way through the string.

This library detects 4 or more consecutive digits and starts encoding them as Type C from the start of the string.

Royal Mail and other UPU barcodes all seem to be encoding from the last pair backward.

For example: TT037117696GB

TCPDF:

  • 104 - START CODE B
  • 52 - T
  • 52 - T
  • 99 - CODE C
  • 03 - 03
  • 71 - 71
  • 17 - 17
  • 69 - 69
  • 100 - CODE B
  • 22 - 6
  • 39 - G
  • 34 - B
  • CHECKSUM = 78
  • 106 - BLANK
  • 107 - STOP

UPU Standard:

  • 104 - START CODE B
  • 52 - T
  • 52 - T
  • 16 - 0
  • 99 - CODE C
  • 37 - 37
  • 11 - 11
  • 76 - 76
  • 96 - 96
  • 100 - CODE B
  • 39 - G
  • 34 - B
  • CHECKSUM = 5
  • 106 - BLANK
  • 107 - STOP

Looking at good old wikipedia:

https://en.wikipedia.org/wiki/Code_128#Barcode_length_optimization

Barcodes can save characters by delaying the C Type encoding until we have a even number of pairs:

"...01234"

... 0 [Code C] 12 34 [checksum] [Stop]

vs

... [Code C] 01 23 [Code A] 4 [checksum] [Stop]

Any chance we can add an optional parameter to force C Type encoding to start from the back of the pairs and encode the remainder separately?

Error

A PHP Error was encountered
Severity: Warning

Message: Uninitialized string offset 19

Filename: CodeOneTwoEight/Process.php

Line Number: 208

Backtrace:

File: /home/parasmstaging/public_html/bhusawal-plant/vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/Process.php
Line: 208
Function: _error_handler

File: /home/parasmstaging/public_html/bhusawal-plant/vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php
Line: 59
Function: getCodeDataC

File: /home/parasmstaging/public_html/bhusawal-plant/vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight.php
Line: 375
Function: getCodeData

File: /home/parasmstaging/public_html/bhusawal-plant/vendor/tecnickcom/tc-lib-barcode/src/Type.php
Line: 171
Function: setBars

File: /home/parasmstaging/public_html/bhusawal-plant/vendor/tecnickcom/tc-lib-barcode/src/Barcode.php
Line: 122
Function: __construct

File: /home/parasmstaging/public_html/bhusawal-plant/application/models/admin/dashboard/gatepass/Md_gatepass.php
Line: 80
Function: getBarcodeObj

File: /home/parasmstaging/public_html/bhusawal-plant/application/controllers/admin/dashboard/gatepass/Cn_gatepass.php
Line: 257
Function: set_barcode

File: /home/parasmstaging/public_html/bhusawal-plant/index.php
Line: 315
Function: require_once

Getting this error

PHP 8.1

OS Ubuntu 20 on webmin

this was working earlier

Additional Info: used C128C : CODE 128 C for barcode generation

Methods getWidth and getHeight of the generated barcode

When the barcode is generated using negative width/height (multiplication factor), it would be useful to be able to get the generated width and height.

Example:

$bobj = $barcode->getBarcodeObj(
    'QRCODE,H',                     // barcode type and additional comma-separated parameters
    'https://tecnick.com',          // data string to encode
    -4,                             // bar width (use absolute or negative value as multiplication factor)
    -4,                             // bar height (use absolute or negative value as multiplication factor)
    'black',                        // foreground color
    array(-2, -2, -2, -2)           // padding (use absolute or negative values as multiplication factors)
    )->setBackgroundColor('white'); // background color
$bobj->getHtmlDiv();
$width = $bobj->getWidth();
$height = $bobj->getHeight();

php8 getPngData

The output under SVG and PNG are different.
PNG is wrong with php8. With php7.4 there is no problem.

Please check

[FeatureRequest] Background color

All barcodes have transparent background color and there is no way to change that.
It is not issue in code but very big usability issue.

I know that this library originates from tcpdf where usually color of a page is white / one print on white page. But now it became more generic and in mine case I use it to generate QRCODES for web pages and mobile devices where background color can vary and it does not depend on me.

I've already mentioned it in #19 but I think it went unnoticed.

QRCode issues

It seems that Imagick generated qr codes have some problems due to float values.
Grayish lines appear in the image.
Rounding and casting values to int in \Com\Tecnick\Barcode\Type::getPngDataImagick fixed this for me.

Imagick 3.4.1,
tc-lib-barcode 1.9.2

Example image http://imgur.com/a/OUeUe.
It will be black due to transparency, just save and view in any image viewer.
Also it would be cool to have ability to set background color.

Code on barcode doesn't match when using special characters with PDF417

Hi,
When I generate a PNG barcode PDF417, with the method getBarcodeObj , my special character is duplicate. I have confirm it with my smartphone.

For example :

$bobj  = $barcode->getBarcodeObj(
    'PDF417',                         
    'abc/abc',
    -4, 
    -4
)->setBackgroundColor('white');

return $bobj->getPngData();

When I scan my barcode, the result doesn't match : "abc//abc"

2 failed tests

PHPUnit 9.5.11 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.27
Configuration: /dev/shm/BUILD/tc-lib-barcode-aca01b1be997404aa14e327f70ef51299423b6c6/phpunit.xml.dist
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

.........EE....................................................  63 / 215 ( 29%)
............................................................... 126 / 215 ( 58%)
............................................................... 189 / 215 ( 87%)
..........................                                      215 / 215 (100%)

Time: 00:02.513, Memory: 16.00 MB

There were 2 errors:

1) Test\BarcodeTest::testGetSvg
Cannot modify header information - headers already sent by (output started at /usr/share/php/PHPUnit9/Util/Printer.php:104)

/dev/shm/BUILDROOT/php-tecnickcom-tc-lib-barcode-1.17.11-1.fc35.remi.x86_64/usr/share/php/Com/Tecnick/Barcode/Type.php:344
/dev/shm/BUILD/tc-lib-barcode-aca01b1be997404aa14e327f70ef51299423b6c6/test/BarcodeTest.php:306

2) Test\BarcodeTest::testGetPng
Cannot modify header information - headers already sent by (output started at /usr/share/php/PHPUnit9/Util/Printer.php:104)

/dev/shm/BUILDROOT/php-tecnickcom-tc-lib-barcode-1.17.11-1.fc35.remi.x86_64/usr/share/php/Com/Tecnick/Barcode/Type.php:456
/dev/shm/BUILD/tc-lib-barcode-aca01b1be997404aa14e327f70ef51299423b6c6/test/BarcodeTest.php:322

ERRORS!
Tests: 215, Assertions: 288, Errors: 2.

Set minimum white bar size?

Is it possible to set how small the smallest white bar can get, as my thermal printer prints a bit thick and often doesn't leave enough room between bars for scanners to be able to read the barcode?

Incorrect Data Matrix

For the string 0&0&0&0&0&0&0_ the library generates an unreadable Data Matrix barcode. And the string 0&0&0&0&0&0&0 turns into 0&0&0&0&0&0&{0.
<?php require ('vendor/autoload.php'); $barcode = new \Com\Tecnick\Barcode\Barcode(); $bobj = $barcode->getBarcodeObj('DATAMATRIX', '0&0&0&0&0&0&_', -4, -4); echo $bobj->getHtmlDiv(); echo "<p></p>"; $bobj = $barcode->getBarcodeObj('DATAMATRIX', '0&0&0&0&0&0&0', -4, -4); echo $bobj->getHtmlDiv();
Bug?
PHP 7.1.1 and 7.4.10, Windows 7 SP1 x64.

DATAMATRIX corruption on certain strings

We generate DATAMATRIX codes strings, e.g.
(400)BS2WZ64PA(00)0
(400)BS2WZ64QA(00)0
The first scans as (400)BS2WZ64V#CB'A<\AW
the second scan fine.

Any ideas where the library is corrupting the string (and why?)
Using an online generator, both of these strings are fine, and the image for the first is different from the one generated by this library.

If you really want your simple example to be simple, you should echo it

The simple example
// output the barcode as HTML div (see other output formats in the documentation and examples)
$bobj->getHtmlDiv();

Does not display anything on the screen and var_dumping $bobj does not give noobs any clues.
A simple fix would be to just change it to

// output the barcode as HTML div (see other output formats in the documentation and examples)
echo $bobj->getHtmlDiv();

Then your example would actually do something tangible.

s25 barcode seems to be wrong

Hello,
There seems to be problems on s25 barcode encoding: start and stop digit are wrong, and digit 8 has the same encoding as digit 0 :
-> start is '11011010' and should be '1110111010'
-> end is '1101011' and should be '111010111'
->digit 8 is '10101110111010' and should be '11101010111010'

GS1 128

I'm having a hard time figuring out what character i should be using for FNC1 (i'm trying to generate GS1 128 barcodes). Btw, is it even possible to generate such barcodes with his library?

php 5.3 compatibility

Really doesn't it work with PHP 5.3?
If it doesn't, would it be difficult to adjust it to 5.3?
Many enterprise linux distributions still use PHP 5.3.

tc-lib-barcode sometimes error creating barcode

Hi, i´m using tc-lib-barcode and sometimes it creates errors when creating barcodes. Using code below with firefox browser. one moment it works fine, and at the next moment it don´t works with the same code and same input. Any ideas?

SSL-error log:

[Wed Jul 14 09:57:09.161085 2021] [php7:error] [pid 225937] [client xxx.xxx.xxx.xxx459] PHP Fatal error: Uncaught Com\Tecnick\Barcode\Exception: The length of each FNC1-separated code block must be even in /var/www/html/barcodegen/vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/Process.php:202\nStack trace:\n#0 /var/www/html/barcodegen/vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/CodeOneTwoEightC.php(59): Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\Process->getCodeDataC(Array, '1234567')\n#1 /var/www/html/barcodegen/vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight.php(375): Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\CodeOneTwoEightC->getCodeData()\n#2 /var/www/html/barcodegen/vendor/tecnickcom/tc-lib-barcode/src/Type.php(171): Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight->setBars()\n#3 /var/www/html/barcodegen/vendor/tecnickcom/tc-lib-barcode/src/Barcode.php(122): Com\Tecnick\Barcode\Type->__construct('1234567', 650, 220, 'black', Array, Array)\n#4 /var/www/html/barcodegen/index.php(51): Com\Tecnick\Barcode\Barcode->getBarcodeObj('C128C', '1234567', 650, in /var/www/html/barcodegen/vendor/tecnickcom/tc-lib-barcode/src/Type/Linear/CodeOneTwoEight/Process.php on line 202, referer: xxx/index.php

My code:

/* <?php
if (! empty($_POST["generate"])) {
require ('vendor/autoload.php');
$barcode = new \Com\Tecnick\Barcode\Barcode();
$targetPath = "barcode/";

if (! is_dir($targetPath)) {
    mkdir($targetPath, 0777, true);
}
$MRP = $_POST["mrp"];
$productData = "{$MRP}";
$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj('C128C', "{$productData}", 650, 220, 'black', array(0, 0, 0, 0));


$imageData = $bobj->getPngData();
$timestamp = time();

file_put_contents($targetPath . $timestamp . '.png', $imageData);
?> */

Changelog

Would be nice if you can have a Changelog this this libraries (and others).

See http://keepachangelog.com/

Yes... I understand this represents some additional work...

Support for official USPS font

I'm getting some inconsistencies in the IMB bar code generator. Using an official USPS generator (requires Flash), I get the following result for the sequence "0027012345678955555590210" — A full screen grab is below.

barcode

Using this library and the IMB type, it generates the following bar code which appears to be entirely different:
screenshot 2019-01-06 12 02 18

I also have some concerns as to whether these bar codes will successfully scan as the USPS requires a specific font.

Has anyone used these bar codes in a production environment?


screenshot 2019-01-06 12 00 24

Wrong end of code 128

Hello, first of all thankyou for your work.
I just tried your library, but it looks like there is a problem with the last line of barcode.
This is a generated barcode:
152152703188_fail
but the scanner fails to recognize it.
This is the same generated barcode but I increased the width of last line:
152152703188_success
and the scanner recognize it.

The code I used is:

require_once('../tc-lib-barcode/vendor/autoload.php');
$barcode = new \Com\Tecnick\Barcode\Barcode();
$obj = $barcode->getBarcodeObj('C128','152152703188',300,50);
$obj->getPng();

Thankyou
P.S.
Are you Italian?

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.