Reputation: 347
I tried to show an variable in header like an Invoice but doesn't work, I using FPDF but the field $ordenTrabajo
is empty, I tried this:
<?php
$ordenTrabajo=$_POST['oT_Escondido'];
ob_end_clean(); // the buffer and never prints or returns anything.
ob_start(); // it starts buffering
class PDF extends FPDF
{
// Cabecera de página
function Header()
{
// Logo
//$this->Image('../dist/img/logo.jpg',10,8,33);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Movernos a la derecha
$this->Cell(80);
// Título
$this->Cell(120,10,'Control de Empaques IKOR PUNTARENAS SA',0,1,'C');
$this->SetFont('Arial','B',12);
// Salto de línea
$this->Ln(10);
$this->Cell(40,10,'Orden de Trabajo: ',0,0);
$this->Cell(40, 10, "GORE-5265", 0, 0);
$this->Cell(13,10,'OC#: ',0,0);
$this->Cell(40, 10, "OC-123456789", 0, 0);
$this->Cell(30,10,'Peso: ',0,0);
$this->Cell(40, 10, "19,45 KG", 0,0 );
$this->Cell(50,10,'Cantidad de Cajas: ',0,0);
$this->Cell(30, 10, "1000", 0, 1);
$this->Cell(20,10,'Lote: ',0,0);
$this->Cell(40, 10,'123456789', 0, 0);
$this->Cell(50,10,'Numero de Parte: ',0,0);
$this->Cell(40, 10, "PARTE-999999", 0, 0);
$this->Cell(40,10,'Filtros por caja: ',0,0);
$this->Cell(20, 10, "11", 0,0 );
$this->Cell(50,10,'Cantidad de Filtros: ',0,0);
$this->Cell(30, 10, "9999", 0, 1);
$this->Ln(15);
$this->Line(80, 45, 100, 45); // 20mm from each edge
$this->Line(50, 45, 210-50, 45); // 50mm from each edge
}
public function setLote($name){
$this->name = $name;
}
// Pie de página
function Footer()
{
// Posición: a 1,5 cm del final
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Número de página
//$this->Cell(300,10,'7FMIKO-022 REV.02',0,0,'C');
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
$this->Cell(-15,10,'7FMIKO-022 REV.02',0,0,'C');
}
}
// Creación del objeto de la clase heredada
$pdf = new PDF('L');
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
$pdf->Cell(30,10,$ordenTrabajo,0,1);
$pdf->Output();
ob_end_flush(); // It's printed here, because ob_end_flush "prints" what's in
// the buffer, rather than returning it
// (unlike the ob_get_* functions)
?>
How could I fix it? Thanx
EDIT
I can't show the value in the header even with the global variable
$ordenTrabajo=$_POST['oT_Escondido'];
ob_end_clean(); // the buffer and never prints or returns anything.
ob_start(); // it starts buffering
class PDF extends FPDF
{
// Cabecera de página
function Header()
{
global $ordenTrabajo;
// Logo
//$this->Image('../dist/img/logo.jpg',10,8,33);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Movernos a la derecha
$this->Cell(80);
// Título
$this->Cell(120,10,'Control de Empaques IKOR PUNTARENAS SA',0,1,'C');
$this->SetFont('Arial','B',12);
// Salto de línea
$this->Ln(10);
$this->Cell(40,10,'Orden de Trabajo: ',0,0);
$this->Cell(40, 10, "GORE-5265", 0, 0);
$this->Cell(13,10,'OC#: ',0,0);
$this->Cell(40, 10, "OC-123456789", 0, 0);
$this->Cell(30,10,'Peso: ',0,0);
$this->Cell(40, 10, "19,45 KG", 0,0 );
$this->Cell(50,10,'Cantidad de Cajas: ',0,0);
$this->Cell(30, 10, "1000", 0, 1);
$this->Cell(20,10,'Lote: ',0,0);
$this->Cell(40, 10,$ordenTrabajo, 0, 0);
$this->Cell(50,10,'Numero de Parte: ',0,0);
$this->Cell(40, 10, "PARTE-999999", 0, 0);
$this->Cell(40,10,'Filtros por caja: ',0,0);
$this->Cell(20, 10, "11", 0,0 );
$this->Cell(50,10,'Cantidad de Filtros: ',0,0);
$this->Cell(30, 10, "9999", 0, 1);
}
Upvotes: 2
Views: 1068
Reputation: 475
This method is used to render the page header. It is automatically called by AddPage() and should not be called directly by the application.The implementation in FPDF is empty, so you have to subclass it and override the method if you want a specific processing.
Source: http://www.fpdf.org/
Upvotes: 1