3
votes

well, I have a very strange problem generating 2D-Barcodes (PDF417) with PHP using TCPDF (TCPDF-Website). This is my small code:

<?php
require_once ("tcpdf/tcpdf_barcodes_2d.php");
$type = "PDF417";
$code="123456789012";
$barcodeobj = new TCPDF2DBarcode($code, $type);
$barcodeobj->getBarcodePNG();
?>

This code works well and generates the barcode. But when I change the line with the code in

$code="1234567890123";

it does not generate any output. I tried several strings and found out, that everytime I try to use a string with more than 12 digits following one after the other I get no output. It does not depend on which position the digits were.

For example:

$code="abcdefghijklmnopqrstuvwxyz123456789012abcdefghijklmnopqrstuvwxyz";

works finde, but

$code="abcdefghijklmnopqrstuvwxyz1234567890123abcdefghijklmnopqrstuvwxyz";

fails.

I use tcpdf 6.0.037 and also tried to download it from annother source. I even tried Version 6.0.020 - no change. Server is openSuSE 12.2 64bit , PHP 5.3.15

Edit: It's getting really strange: I tried annother barcode generator - and I get the same error. This one provides a online demo. When I fill in 1234567890123 online, I get the appropreate barcode. But on my own server the same string does not work.

"123456-7890123" works
"1234567890123" does not work
"123456789012" works
"12e34567890123" works
"123456789012sometext123456789012" works
"123456789012sometext1234567890123" does not work

Every string with more than 12 numbers in a row does not work - no matter how long the string is.

U see what I mean with "strange" ?

Any help would be highly appreciated.

1

1 Answers

2
votes

I too had this problem. We are using PDF417 & QR Code barcodes. I have not found a great solution for this, but I have found a solution that works for now. If anyone has a better solution, please advise.

Problem: In our barcodes we have phone numbers that are stored and sometimes they are 13 digits or longer. The 13 digit phone number was causing the barcode to not print correctly.

Solution: Since the barcode would not print due to this we just add a space every 10 digits and this keeps the barcode intact and our software can read in the phone number without spaces so we should be A-OK!

Example Phone Number:
123456789012345 (15 digits)

PHP Code to run on phone number:
$phone = chunk_split($phone, 10, ' ');

Example Phone Number after split:
1234567890 12345

The libraries for these barcodes (Google/TCPDF) don't like numbers longer than 12 so it's definitely strange, but maybe I"m missing something easy to see.

Thanks and hope this helps someone.