estoy trabajando en una aplicación que está desarrollada en PHP. En ella, tengo un informe en formato PDF, el cual me muestra datos de pacientes. En él, necesito insertarle un código de barra que como valor tenga el rut del paciente.
Sé que existen infinidades de librerias FPDF para ello, de hecho ya tengo una en el servidor. El tema es que no cacho como implementar el código para que se me vea el código de barras. Actualmente, en archivos normales escritos en código PHP, no tengo problemas para llamar a la función que me muestra el código, que es ésta:
Código PHP:
function code_bar($output,$barcode,$type,$width,$height,$xres,$font,$ruta_palo)
{
define (__TRACE_ENABLED__, false);
define (__DEBUG_ENABLED__, false);
//librerias para el código de barras
require_once("$ruta_palo/barcode/barcode.php");
require_once("$ruta_palo/barcode/c128bobject.php");
require_once("$ruta_palo/barcode/c128aobject.php");
require_once("$ruta_palo/barcode/c128cobject.php");
require_once("$ruta_palo/barcode/c39object.php");
require_once("$ruta_palo/barcode/i25object.php");
/*********************************/
/* Default value */
if (!isset($output)) $output = "jpeg";
if (!isset($barcode)) $barcode = "0123456789";
if (!isset($type)) $type = "C128B";
if (!isset($width)) $width = "130";
if (!isset($height)) $height = "40";
if (!isset($xres)) $xres = "1";
if (!isset($font)) $font = "1";
/*********************************/
if (isset($barcode) && strlen($barcode)>0) {
$style = BCS_ALIGN_CENTER;
$style |= ($output == "png" ) ? BCS_IMAGE_PNG : 0;
$style |= ($output == "jpeg") ? BCS_IMAGE_JPEG : 0;
$style |= ($border == "on" ) ? BCS_BORDER : 0;
$style |= ($drawtext== "on" ) ? BCS_DRAW_TEXT : 0;
$style |= ($stretchtext== "on" ) ? BCS_STRETCH_TEXT : 0;
$style |= ($negative== "on" ) ? BCS_REVERSE_COLOR : 0;
switch ($type)
{
case "I25":
$obj = new I25Object(250, 120, $style, $barcode);
break;
case "C39":
$obj = new C39Object(250, 120, $style, $barcode);
break;
case "C128A":
$obj = new C128AObject(250, 120, $style, $barcode);
break;
case "C128B":
$obj = new C128BObject(250, 120, $style, $barcode);
break;
case "C128C":
$obj = new C128CObject(250, 120, $style, $barcode);
break;
default:
$obj = false;
}
if ($obj)
{
if ($obj->DrawObject($xres))
{
echo "<table align='right'><tr><td align='right'><img src='$ruta_palo/barcode/image.php?code=".$barcode."&style=".$style."&type=".$type."&width=".$width."&height=".$height."&xres=".$xres."&font=".$font."'></td></tr></table>";
} else echo "<table align='center'><tr><td><font color='#FF0000'>".($obj->GetError())."</font></td></tr></table>";
}
}
}
Código PHP:
<td class='campos'><div valing='bottom'>";
code_bar("jpeg",$rut_paciente,"C128B",170,40,1,1,$ruta_palo_1);
</td>
Código PHP:
echo "<table align='right'><tr><td align='right'><img src='$ruta_palo/barcode/image.php?code=".$barcode."&style=".$style."&type=".$type."&width=".$width."&height=".$height."&xres=".$xres."&font=".$font."'></td></tr></table>";
} else echo "<table align='center'><tr><td><font color='#FF0000'>".($obj->GetError())."</font></td></tr></table>";
Espero me puedan ayudar.
Gracias de antemano.