[Ayuda] Reportes con FPDF con imagen de fondo

Iniciado por Only, Abril 15, 2015, 01:42:49 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Abril 15, 2015, 01:42:49 PM Ultima modificación: Abril 15, 2015, 02:03:59 PM por Gabriela
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

Código: php

<?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();
?>


Abril 16, 2015, 12:52:56 PM #1 Ultima modificación: Abril 16, 2015, 12:58:34 PM por kid_goth
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

<?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();
?>

No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Acepta con humildad y aprecio que en la vida la muerte es inevitable y amarás ésta, adorando la muerte