Foros del Web » Programando para Internet » PHP »

Problema crear PDF con TCPDF

Estas en el tema de Problema crear PDF con TCPDF en el foro de PHP en Foros del Web. Hola tengo un problema de lo mas raro, me baje la ultima versión de TCPDF y si ejecuto los ejemplos que trae, mas precisamente el ...
  #1 (permalink)  
Antiguo 25/07/2008, 06:43
Avatar de maderic_m  
Fecha de Ingreso: agosto-2007
Mensajes: 53
Antigüedad: 16 años, 7 meses
Puntos: 0
Problema crear PDF con TCPDF

Hola tengo un problema de lo mas raro, me baje la ultima versión de TCPDF y si ejecuto los ejemplos que trae, mas precisamente el nro.: 06 este me muestra el HTML correctamente y hace justo lo que preciso, pero ahora bien resulta que comencé a modificar el código fuente para poder adaptar la clase a mi aplicación y no se por que motivo deja de interpretar el HTML y deja todo como una cadena de texto.
Primero lo que hice fue colocar en una ruta distinta el archivo para generar el PDF y hacia eso que describí arriaba, luego lo que hice fue colocar en la misma ruta que el ejemplo06 y sigue haciendo lo mismo (en ambos caso las ruta de los includes estaba bien).

Este es el código del ejemplo:
http://www.tecnick.com/pagefiles/tcpdf/example_006.phps

Este es el código que modifique yo(solo quite partes del original):
Código PHP:
require_once('../config/lang/eng.php');
require_once(
'../tcpdf.php');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATIONPDF_UNITPDF_PAGE_FORMATtrue);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor("Nicola Asuni");
$pdf->SetTitle("TCPDF Example 006");
$pdf->SetSubject("TCPDF Tutorial");
$pdf->SetKeywords("TCPDF, PDF, example, test, guide");

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGOPDF_HEADER_LOGO_WIDTHPDF_HEADER_TITLEPDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN''PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA''PDF_FONT_SIZE_DATA));

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFTPDF_MARGIN_TOPPDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUEPDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

//initialize document
$pdf->AliasNbPages();

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

// ---------------------------------------------------------

// set font
$pdf->SetFont("freeserif"""11);

// create some HTML content
$htmlcontent "<h1>HTML Example</h1>&lt; € &euro; € &amp; è &egrave; &copy; &gt; \\slash \\\\double-slash \\\\\\triple-slash<h2>List</h2>List example:<ol><li><b>bold text</b></li><li><i>italic text</i></li><li><u>underlined text</u></li><li><a href=\"http://www.tecnick.com\" dir=\"ltr\">link to http://www.tecnick.com</a></li><li>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.<br />Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</li><li>SUBLIST<ol><li>row one<ul><li>sublist</li></ul></li><li>row two</li></ol></li><li><b>T</b>E<i>S</i><u>T</u> <del>line through</del></li><li><font size=\"+3\">font + 3</font></li><li><small>small text</small> normal <small>small text</small> normal <sub>subscript</sub> normal <sup>superscript</sup> normal</li></ol><dl><dt>Coffee</dt><dd>Black hot drink</dd><dt>Milk</dt><dd>White cold drink</dd></dl><div style=\"text-align:center\">IMAGES<br /><img src=\"../images/logo_example.png\" alt=\"test alt attribute\" width=\"100\" height=\"100\" border=\"0\" align=\"top\" /><img src=\"../images/logo_example.gif\" alt=\"test alt attribute\" width=\"100\" height=\"100\" border=\"0\" align=\"top\" /><img src=\"../images/logo_example.jpg\" alt=\"test alt attribute\" width=\"100\" height=\"100\" border=\"0\" /></div>";

// output the HTML content
$pdf->writeHTML($htmlcontenttrue0true0);

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

//Close and output PDF document
$pdf->Output("example_006.pdf""I""I"); 
Y esta es la salida del PDF:
Código:
<h1>HTML Example</h1>< � € € & �è © > \slash \\double-slash \\\triple-slash<h2>List</h2>List
example:<ol><li><b>bold text</b></li><li><i>italic text</i></li><li><u>underlined text</u></li><li><a
href="http://www.tecnick.com" dir="ltr">link to http://www.tecnick.com</a></li><li>Sed ut perspiciatis unde
omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab
illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.<br />Nemo enim ipsam voluptatem
quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem
sequi nesciunt.</li><li>SUBLIST<ol><li>row one<ul><li>sublist</li></ul></li><li>row
two</li></ol></li><li><b>T</b>E<i>S</i><u>T</u> <del>line through</del></li><li><font size="+3">font +
3</font></li><li><small>small text</small> normal <small>small text</small> normal <sub>subscript</sub>
normal <sup>superscript</sup> normal</li></ol><dl><dt>Coffee</dt><dd>Black hot
drink</dd><dt>Milk</dt><dd>White cold drink</dd></dl><div style="text-align:center">IMAGES<br /><img
src="../images/logo_example.png" alt="test alt attribute" width="100" height="100" border="0" align="top"
/><img src="../images/logo_example.gif" alt="test alt attribute" width="100" height="100" border="0" align="top"
/><img src="../images/logo_example.jpg" alt="test alt attribute" width="100" height="100" border="0" /></div>
La verdad que no entiendo que pasa, ¿alguna idea? Gracias
  #2 (permalink)  
Antiguo 25/07/2008, 09:41
Avatar de maderic_m  
Fecha de Ingreso: agosto-2007
Mensajes: 53
Antigüedad: 16 años, 7 meses
Puntos: 0
Respuesta: Problema crear PDF con TCPDF

Bueno ahí empezó a funcionar, la verdad el único error que encontré fue un pequeño error en el HTML que se iba a imprimir, se que en el paso de copiar y pegar, ya sea mi editor o yo accidentalmente toque el código y eso producid ese error, saludos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:15.