excelente script!! gera código de barra no modelo Code39, muito bom... index.php <?
include_once ("barcode.php");
include_once ("classBarraC.php");
$texto = $HTTP_POST_VARS["texto"];
$tam = $HTTP_POST_VARS["tam"];
?>
<html>
<head>
<title></title>
<link rel="stylesheet" href="padrão.css" type="text/css">
</head>
<body>
<form name="form1" method="post" action="index.php">
<div align="center">Digite o texto:
<input type="text" name="texto" value="<?=$texto?>">
Selecione o tamanho:
<select name="tam">
<?for ($i=1;$i<10;$i++){
echo "<option value='$i' ";
if ($tam == $i) {
echo "selected";
}
echo ">$i</option>";
}?>
</select>
<input type="submit" name="Submit" value="Mostrar">
</div>
</form>
<p> </p>
<p>
<?
if ($texto){
echo "Code 39: ";
barcode($texto,$tam);
//Substitua o valor do parâmetro abaixo pelo número do código de barras.
//instânciando a classe
echo "<br>";
echo "Code 25: ";
WBarCode::WBarCode( $texto );
}?>
</p>
</body>
</html>
barcode.php
<?
Function barcode($texto, $tam=1,$path="imgbarra/"){
if ($texto){
$w = 86 / $tam;
$h = 200 / $tam;
$e = 6 / $tam;
if (file_exists($path."ini.png") && file_exists($path."esp.png")){
echo "<img src='".$path."ini.png' width='$w' height='$h'>";
echo "<img src='".$path."esp.png' width='$e' height='$h'>";
$texto = strtolower($texto);
for ($i=0;$i<=strlen($texto)-1;$i++){
$var = substr($texto,$i,1);
if ($var == "/" && file_exists($path."bar.png")){
echo "<img src='".$path."bar.png' width='$w' height='$h'>";
$var = "";
}
if ($var == "*" && file_exists($path."ast.png")){
echo "<img src='".$path."ast.png' width='$w' height='$h'>";
$var = "";
}
if ($var == "%" && file_exists($path."per.png")){
echo "<img src='".$path."per.png' width='$w' height='$h'>";
$var = "";
}
if ($var == "." && file_exists($path."pnt.png")){
echo "<img src='".$path."pnt.png' width='$w' height='$h'>";
$var = "";
}
if ((!($var=="")) && (file_exists($path."$var.png"))){
echo "<img src='".$path."$var.png' width='$w' height='$h'>";
}
echo "<img src='".$path."esp.png' width='$e' height='$h'>";
}
echo "<img src='".$path."ini.png' width='$w' height='$h'>";
}else{
echo "BarCode erro: Faltam figuras do ini.png ou esp.png!";
}
}
}
?>
Agora o codigo de barra padrão
<html>
<?
/*
Rotina para gerar códigos de barra padrão 2of5 ou 25.
####################
Orientado a Objeto
####################
*/
class WBarCode
{
//variaveis privadas
var $_fino;
var $_largo;
var $_altura;
//variaveis publicas
var $BarCodes = array();
var $texto;
var $matrizimg;
var $f1;
var $f2;
var $f;
var $i;
var $matrizimg;
//Construtor da class
function WBarCode($Valor){
$this->fino=1;
$this->largo=3;
$this->altura=50;
if (empty($this->BarCodes[0]))
{
$this->BarCodes[0]="00110";
$this->BarCodes[1]="10001";
$this->BarCodes[2]="01001";
$this->BarCodes[3]="11000";
$this->BarCodes[4]="00101";
$this->BarCodes[5]="10100";
$this->BarCodes[6]="01100";
$this->BarCodes[7]="00011";
$this->BarCodes[8]="10010";
$this->BarCodes[9]="01010";
for ($this->f1=9; $this->f1>=0; $this->f1=$this->f1-1)
{
for ($this->f2=9; $this->f2>=0; $this->f2=$this->f2-1)
{
$this->f=$this->f1*10+$this->f2;
$this->texto="";
for ($this->i=1; $this->i<=5; $this->i=$this->i+1)
{
$this->texto=$this->texto.substr($this->BarCodes[$this->f1],$this->i-1,1).
substr($this->BarCodes[$this->f2],$this->i-1,1);
}
$this->BarCodes[$this->f]=$this->texto;
}
}
}
//Desenho da barra
// Guarda inicial
$this->matrizimg.= "
<img src=p.gif width=$this->fino height=$this->altura border=0><img
src=b.gif width=$this->fino height=$this->altura border=0><img
src=p.gif width=$this->fino height=$this->altura border=0><img
src=b.gif width=$this->fino height=$this->altura border=0><img
";
$this->texto=$Valor;
if (strlen($this->texto)%2<>0)
{
$this->texto="0".$this->texto;
}
// Draw dos dados
while(strlen($this->texto)>0)
{
$this->i=intval(substr($this->texto,0,2));
$this->texto=substr($this->texto,strlen($this->texto)-(strlen($this->texto)-2));
$this->f=$this->BarCodes[$this->i];
for ($this->i=1; $this->i<=10; $this->i=$this->i+2)
{
if (substr($this->f,$this->i-1,1)=="0")
{
$this->f1=$this->fino;
}
else
{
$this->f1=$this->largo;
}
$this->matrizimg.="src=p.gif width=$this->f1 height=$this->altura border=0><img
";
if (substr($this->f,$this->i+1-1,1)=="0")
{
$this->f2=$this->fino;
}
else
{
$this->f2=$this->largo;
}
$this->matrizimg.= "src=b.gif width=$this->f2 height=$this->altura border=0><img ";
}
}
$this->matrizimg.= "src=p.gif width=$this->largo height=$this->altura border=0><img src=b.gif width=$this->fino height=$this->altura border=0><img
src=p.gif width=1 height=$this->altura border=0>";
//escreve todo o codigo da barra na tela...
echo $this->matrizimg;
}//fim da function
}//fim da Class
//Substitua o valor do parâmetro abaixo pelo número do código de barras.
//instânciando a classe
WBarCode::WBarCode( "85710000000000000673028082002010201200200057" );
?>
</html> Tmb não sei se erra isso q você quiria, até..