Cdigo PHP:
// test the table functions
error_reporting(E_ALL);
include('class.ezpdf.php');
$pdf =& new Cezpdf('A4','portrait');
$pdf->selectFont('./fonts/Helvetica');
$pdf->ezStartPageNumbers(500,18,10,'','{PAGENUM} de {TOTALPAGENUM}',1);
// coloca una linea arriba y abajo de todas las paginas
$all = $pdf->openObject();
$pdf->saveState();
$pdf->setStrokeColor(0,0,0,1);
$pdf->line(20,30,750,30);
$pdf->line(20,585,750,585);
$pdf->addText(20,590,10,'[Programa Internacional de Becas]');
$pdf->addText(400,18,10,'Pagina');
$pdf->restoreState();
$pdf->closeObject();
// termina las lineas
$pdf->addObject($all,'all');
//--------
//--------------------------------------------------
// you will have to change these to your settings
$host = '127.0.0.1';
$user = 'root';
$password = '';
$database = 'ford';
$query = "select cod_postulante, nombres, apel_pat, apel_mat, promed_final ";
$query.="from promedio_notas limit 0,10";
//--------------------------------------------------
// open the connection to the db server
$link = mysql_connect($host,$user,$password);
// change to the right database
mysql_select_db($database);
// initialize the array
$data = array();
// do the SQL query
$result = mysql_query ($query ) or die (mysql_error());
// step through the result set, populating the array, note that this could
//Aqui se coloca el header de la Tabla
$cols = array('cod_postulante'=>'Cdigo',
'nombre'=>'Nombres y apellidos',
'promed_final'=>'Nota');
$smc=0;
//also have been written:
// while($data[] = mysql_fetch_assoc($result)) {}
while($fila = mysql_fetch_array($result, MYSQL_NUM))
{
$cod_postulante=$fila[0];
$nombre=$fila[1]." ".$fila[2]." ".$fila[3];
$promed_final=$fila[4];
$smc = $smc + 1;
// Aqui agrego los campos formateados al array
$data[] = array('cod_postulante'=>$cod_postulante,
'nombre'=>$nombre,
'promed_final'=>$promed_final);
}
$nreg = 'Numero de Registros : '.$smc ;
// make the table
$pdf->ezTable($data,$cols,'',array('fontSize'=>6,
'cols'=>array( 'cod_postulante'=>array('justification'=>'center')
,'nombre'=>array('justification'=>'left')
,'promed_final'=>array('justification'=>'left'))));// salida
// do the output, this is my standard testing output code, adding ?d=1
// to the url puts the pdf code to the screen in raw form, good for
//checking
// for parse errors before you actually try to generate the pdf file.
if (isset($d) && $d){
$pdfcode = $pdf->output();
$pdfcode = str_replace("\n","\n<br>",htmlspecialchars($pdfcode));
echo '<html><body>';
echo trim($pdfcode);
echo '</body></html>';
} else {
$pdf->stream();
}
y esta es la basurita que me sale..:s
%PDF-1.3 % 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [6 0 R ] /Count 1 /Resources << /ProcSet 4 0 R /Font << /F1 8 0 R >> >> /MediaBox [0.000 0.000 595.280 841.890] >> endobj 4 0 obj [/PDF /Text ] endobj 5 0 obj << /Creator (R and OS php pdf writer, http://www.ros.co.nz) /CreationDate (D:20040302) >> endobj 6 0 obj << /Type /Page /Parent 3 0 R /Contents [ 7 0 R 9 0 R 10 0 R ] >> endobj 7 0 obj << /Filter /FlateDecode /Length 207 >> stream x=n1~Oʤ JE vADD4 ĬAB35犉q:Ed8os@, cG ^J<&fb"x?v-f?jl͉)8g̥K ibĨAL(0%[o:P-|$pVBCt~zBM +r endstream endobj 8 0 obj << /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >> endobj 9 0 obj << /Filter /FlateDecode /Length 131 >> stream x*2300P@&ܹ ,c`n" Sbja&RSg CR <4耢DϼԢTXM,Y &C -.2 endstream endobj 10 0 obj << /Filter /FlateDecode /Length 561 >> stream xMo0 ,+cH MH̅cJa;ikH |D5$¢L ;QEoD"¨b=8itBjVSʪl`. S u* ,wH S0V LM 3acCa2%4BRֵט))LF彇es珐G 6(N8(_N+)rK|Tl"e(xm1K4 7QM^<ل.vOQBak_# ;u&-h\_4jbPb. hFص&G`1DOk6(%c5XFsc -`vtJ1·*I_d؉/-,ԻSL)f &p&f||5SXbO PAe^,'@H1HD pRk"ֹ69S'нKm25\e:]{K%dj)cO _нz]˒z] endstream endobj xref 0 11 0000000000 65535 f 0000000015 00000 n 0000000080 00000 n 0000000126 00000 n 0000000280 00000 n 0000000309 00000 n 0000000414 00000 n 0000000494 00000 n 0000000774 00000 n 0000000881 00000 n 0000001085 00000 n trailer << /Size 11 /Root 1 0 R /Info 5 0 R >> startxref 1720 %%EOF