WebjxCom提示:
PHP5实例教程简简单单生成条形码.
mytest.php代码:
<imgsrc="test.php?codebar=BCGcode39&text=20090729">
PHP5生成条形码效果图:
PHP5生成条形码test.php代码:
<?php
//Includingallrequiredclassesrequire('class/BCGFont.php');
require('class/BCGColor.php');require('class/BCGDrawing.php');
/*'BCGcodabar','BCGcode11','BCGcode39','BCGcode39extended','BCGcode93','BCGcode128','BCGean8','BCGean13','BCGisbn','BCGi25','BCGs25','BCGmsi',
'BCGupca','BCGupce','BCGupcext2','BCGupcext5','BCGpostnet','BCGothercode'*/$codebar=$_REQUEST['codebar'];//该软件支持的所有编码
,只需调整$codebar参数即可
。 //Includingthebarcodetechnologyinclude('class/'.$codebar.'.barcode.php');
//LoadingFont$font=newBCGFont('./class/font/Arial.ttf',10);
//TheargumentsareR,G,Bforcolor.$color_black=newBCGColor(0,0,0);
$color_white=newBCGColor(255,255,255);$code=new$codebar();
$code->setScale(2);//Resolution$code->setThickness(30);//Thickness
$code->setForegroundColor($color_black);//Colorofbars$code->setBackgroundColor($color_white);//Colorofspaces
$code->setFont($font);//Font(or0)$text=$_REQUEST['text'];//PHP5生成条形码将要数据的内容
$code->parse($text);/*Hereisthelistofthearguments
1-Filename(empty:displayonscreen)2-Backgroundcolor*/
$drawing=newBCGDrawing('',$color_white);$drawing->setBarcode($code);
$drawing->draw();//Headerthatsaysitisanimage(removeitifyousavethebarcodetoafile)
header('Content-Type:image/png');//Draw(orsave)theimageintoPNGformat.
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>