PDA

View Full Version : Cannot generate barcode



csanpedro
04-03-2008, 08:41 PM
Hi i cannot use my 3of9 barcode generator script to print employee id-code here at free-space.



<?php
//set the content type this page returns
header('Content-type: image/png');

//set values
$size = 35;
$width = 300;
$height = $size;
$id = $_REQUEST['txtEmployee'];

//align the barcode at the bottom and one pixel from the left
$startlocation_y = $height;
$startlocation_x = 1;

//create and image of the correct size
$im = imagecreate($width,$height);
//add the black and white colours to the image
$white = imagecolorallocate($im,255,255,255);
$black = imagecolorallocate($im,0,0,0);
$font = '3OF9.TTF';
$text = $id;

//write the barcode text to the image using the “3 of 9”
//barcode font which must be in the same directory.
//The $black colour is negated to remove anti-aliasing.
//The 0 indicates the angle of the text.
imagettftext($im, $size, 0, $startlocation_x, $startlocation_y, -$black, $font, $text);

//return the image and release resources
imagepng($im);
imagedestroy($im);
?>

Penguin
04-04-2008, 04:11 AM
What's the error given? Look in the error_log file.

csanpedro
04-04-2008, 07:22 PM
i'm sorry but where is error_log file located?

but when i try it on the web browser, the error message is already written on the image and it says "The image preview.php cannot be displayed because it contains errors".

So i guess the image generator works fine and the error is at the barcode printing.
I tried this at my local computer and it works fine.

Please help me

csanpedro
04-04-2008, 07:35 PM
I think its because gd2 library is disabled here at free-space..

James
04-05-2008, 03:11 AM
GD2 is installed...

Penguin
04-05-2008, 05:31 AM
Hmm James, could you check if FreeType2 is installed on the server? That seems to be the cause of the problem.