text files - How to generate and save multi barcodes into folder by php?
Get the solution ↓↓↓I have tried to generate many barcodes by barcode generator. There are many codes I have put in text.txt. But It is fail after I run below codes. Is there any mistakes? Please help.
Here is text.txt
ABC0000001
ABC0000002
ABC0000003
Here is my code:
<?php
require_once('class/BCGFontFile.php');
require_once('class/BCGColor.php');
require_once('class/BCGDrawing.php');
require_once('class/BCGcode128.barcode.php');
//I run the barcode text one by one here
foreach(file('text.txt') as $line) {
$font = new BCGFontFile('./font/Arial.ttf', 18);
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
$text = $line;
$code = new BCGcode128();
$code->setScale(1);
$code->setThickness(30);
$code->setForegroundColor($color_black);
$code->setBackgroundColor($color_white);
$code->setFont($font);
$code->parse("'".$text."'"); // Text
$drawing = new BCGDrawing('images/filename'.$text.'.jpg', $color_white);
$drawing->setBarcode($code);
$drawing->draw();
$drawing->finish(BCGDrawing::IMG_FORMAT_JPEG);
}
?>
Below is the error section
$c = count($posArray);
for ($i = 0; $i < $c; $i++) {
if (($curLen[$posArray[$i]] + $charSiz[$posArray[$i]]) < $nxtLen[$posArray[$i]]) {
$nxtLen[$posArray[$i]] = $curLen[$posArray[$i]] + $charSiz[$posArray[$i]];
$nxtSeq[$posArray[$i]] = $curSeq[$posArray[$i]] . '.';
}
for ($j = 0; $j < 2; $j++) {
if ($j === $posArray[$i]) { continue; }
if (($curLen[$j] + $shftLen[$j][$posArray[$i]] + $charSiz[$posArray[$i]]) < $nxtLen[$j]) {
$nxtLen[$j] = $curLen[$j] + $shftLen[$j][$posArray[$i]] + $charSiz[$posArray[$i]];
$nxtSeq[$j] = $curSeq[$j] . chr($posArray[$i] + 65) . '.';
}
}
}
if ($c === 0) {
// We found an unsuported character
throw new BCGParseException('code128', 'Character ' . $input . ' not supported.');
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: closed without sending a request; it was probably just an unused speculative preconnection
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.