Underc0de

Foros Generales => Dudas y pedidos generales => Mensaje iniciado por: Only en Abril 15, 2015, 01:42:49 PM

Título: [Ayuda] Reportes con FPDF con imagen de fondo
Publicado por: Only en Abril 15, 2015, 01:42:49 PM
Hola a todos, estoy realizando unos reportes con FPDF en el cual tengo que imprimir unos registros traidos de la base de datos mediante una consulta, el reporte tiene una imagen de fondo , pero no me imprime los datos, espero me puedan orientar, dejo el codigo


<?php 
obstart
();
include(
"fpdf.php");
include(
"../conexion/startconnection.php");
include(
"../header.php");

$id = (int)$GET['id'];
$consulta mysqliquery($conexion,"SELECT * FROM inventario WHERE id='$id'");
$row mysqlifetcharray($consulta);

class 
PDF extends FPDF
{

function 
hoja1()
{

$this->Image('imagen.jpg','0','0','210','297','JPG'); 
//IMAGE (RUTA,X,Y,ANCHO,ALTO,EXTEN)

//distancia entre el tope de la hoja y la primer linea
$this->Ln(30);

//Letra , tipo y tamaño
$this->SetFont('Arial','B',9);

$this->Cell(32);
$this->Cell(0,5,utf8decode('Clave Unica'.$row['claveunica]),0,1,'L');
$this->Cell(32);
$this->Cell(0,5,utf8decode('
Clave C.A.B.M.S.'.$row['clave']),0,1,'L');
$this->Cell(32);
$this->Cell(0,5,utf8decode('
Clasificación'.$row['clasificacion]),0,1,'L');
$this->Cell(32);
$this->Cell(0,5,utf8_decode('Descripción'.$row['descripcion]),0,1,'L');


}

$pdf = new PDF(); //constructor pdf
$pdf->SetFont('
Arial','',8);
$pdf->AddPage();
$pdf->hoja1();
obendclean();
$pdf->Output();
obendflush(); 
?>


Título: Re:[Ayuda] Reportes con FPDF con imagen de fondo
Publicado por: kid_goth en Abril 16, 2015, 12:52:56 PM
hola bro, asi viendolo por encima veo que no estas cerrando las comillas del array $row al momento de asignarlo a la celda.


entonces si te fijas por ejemplo desde esta linea $this->Cell(0,5,utf8decode('Clave Unica'.$row['claveunica]),0,1,'L'); deberias arreglarla asi: $this->Cell(0,5,utf8decode('Clave Unica'.$row['claveunica']),0,1,'L'); por otro lado están mal las funciones de mysqli, no es mysqliquery sino mysqli_query y tampoco es mysqlifetcharray sino mysqli_fetch_array  eso debería solucionar tu problema, aquí el code completo por si acaso:

Código (php) [Seleccionar]

<?php 
obstart
();
include(
"fpdf.php");
include(
"../conexion/startconnection.php");
include(
"../header.php");

$id = (int)$GET['id'];
$consulta mysqli_query($conexion,"SELECT * FROM inventario WHERE id='$id'");
$row mysqli_fetch_array($consulta);

class 
PDF extends FPDF
{

function 
hoja1()
{

$this->Image('imagen.jpg','0','0','210','297','JPG'); 
//IMAGE (RUTA,X,Y,ANCHO,ALTO,EXTEN)

//distancia entre el tope de la hoja y la primer linea
$this->Ln(30);

//Letra , tipo y tamaño
$this->SetFont('Arial','B',9);

$this->Cell(32);
$this->Cell(0,5,utf8decode('Clave Unica'.$row['claveunica']),0,1,'L');
$this->Cell(32);
$this->Cell(0,5,utf8decode('Clave C.A.B.M.S.'.$row['clave']),0,1,'L');
$this->Cell(32);
$this->Cell(0,5,utf8decode('Clasificación'.$row['clasificacion']),0,1,'L');
$this->Cell(32);
$this->Cell(0,5,utf8_decode('Descripción'.$row['descripcion']),0,1,'L');


}

$pdf = new PDF(); //constructor pdf
$pdf->SetFont('Arial','',8);
$pdf->AddPage();
$pdf->hoja1();
obendclean();
$pdf->Output();
obendflush(); 
?>