0

I am using the following code to generate barcode in php using barcodephp this script

<?php
require('class/BCGFontFile.php');
require('class/BCGColor.php');
require('class/BCGDrawing.php');
require('class/BCGean13.barcode.php');

$font = new BCGFontFile('fontArial.ttf', 18);
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);

// Barcode Part
$code = new BCGean13();
$code->setScale(2);
$code->setThickness(30);
$code->setForegroundColor($color_black);
$code->setBackgroundColor($color_white);
$code->setFont($font);
$code->parse('578124871412');

// Drawing Part
$drawing = new BCGDrawing('', $color_white);
$drawing->setBarcode($code);
$drawing->draw();

header('Content-Type: image/png');

$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>

I am getting following error, i have checked locations of library and everything is fine

enter image description here

What is the problem ??

4
  • the Problem is, that you or the code try to declare class BCGColor twice .. second declare is in BCGColor.php Line 11 ... Commented Jan 12, 2015 at 7:29
  • @donald123 where i am redeclaring BCGDrawing in this file ?? Commented Jan 12, 2015 at 7:32
  • @donald123 i am only including it Commented Jan 12, 2015 at 7:33
  • 1
    It would appear that BCGFontFile already includes BCGColor and your inclusion is resulting in a duplicate definition. Try require_once. Commented Jan 12, 2015 at 9:02

1 Answer 1

1

Okay i found the solution, just remove

require('class/BCGFontFile.php');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.