Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/04/2012, 05:44
AlejandroFerrer44025
 
Fecha de Ingreso: abril-2012
Ubicación: Valencia
Mensajes: 7
Antigüedad: 12 años
Puntos: 0
Respuesta: Error al abrir PDF creado con TCPDF

ob_start();
$Contenido=new plantilla("web");
$Contenido->asigna_variables(array(
"razon_social" => "$razon_social",
"direccion" => "$direccion",
"cp" => "$CP",
"poblacion" => "$poblacion",
"provincia" => "$provincia",
"web" => "$web"
));

//$ContenidoString contiene nuestra plantilla, ya con las variables asignadas
$ContenidoString = $Contenido->muestra();
print "$ContenidoString";

print "<div align=\"center\"><br/>";
print "<form action=\"$PHP_SELF\" method=\"post\">";
print "<input type=\"submit\" name=\"pdf\" value=\"Imprimir PDF\" />";
print "</form></div>";


if ($_REQUEST['pdf']=="Imprimir PDF") {

$salida = ob_get_contents();
#$salida = utf8_decode($salida);
ob_clean();

require_once('../../modulos/tcpdf/config/tcpdf_config.php');
require_once('../../modulos/tcpdf/config/lang/spa.php');
require_once('../../modulos/tcpdf/tcpdf.php');

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// add a page
$pdf->AddPage();

// set font
$pdf->SetFont('dejavusans', '', 10);

// output the HTML content
$pdf->writeHTML($salida, true, 0, true, true);

// reset pointer to the last page
$pdf->lastPage();

//Close and output PDF document
$pdf->Output("Formulario Web para $usuario.pdf", 'D');

}


$salida contiene un código HTML creado a partir de una plantilla