A CONTINUACIÓN LES DEJO UN ARHIVO PARA PODER GENERAR UN ARCHIVO PDF CON PHP.
PARA ELLO UTILIZAREMOS LA LIBRERIA DE EZPDF
ABAJO EL CODIGO FUENTE
1: <?php
2:
3: //DomPDF
4:
5:
6: require_once('class.ezpdf.php'); //IMPORTAMOS LA LIBRERIA DE EZPDF
7: include ('conexionmysql.php'); //IMPORTAMOS LA LIBRERIA PARA REALIZAR LA CONEXIÓN CON MYSQL
8:
9: $pdf =& new Cezpdf('LETTER'); //SELECCIONAMOS EL EL TAMAÑO DE HOJA DEL ARCHIVO PDF, EN ESTE CASO SERA TAMAÑO CARTA
10: $pdf->selectFont('../fonts/courier.afm'); //SELECCIONAMOS EL TIPO DE LETRA
11: $pdf->ezSetCmMargins(1,1,1.5,1.5); //AQUI VA LOS MARGENES DE LAHOJA
12:
13:
14: //GUARDAREMOS EN UNA VARIABLE LOS DATOS PARA LA CONEXIÓN AL GESTOR DE BASE DE DATOS
15: $direccion1="localhost";
16: $usuario1="root";
17: $password1="";
18: $basededatos1="bd_itlm";
19:
20:
21: //NOS CONECTAMOS A LA BASE DE DATOS LLAMANDO LA FUNCIÓN cononectar_mysql() UTILIZANDO LAS VARIABLES DE ARRIBA
22: conectar_mysql("$direccion1","$usuario1","$password1","$basededatos1");
23:
24:
25: //GUARDAMOS LA CADENA PARA REALIZAR LA CONSULTA
26: $Presta = "SELECT * FROM usuarios ORDER BY id ASC";
27:
28: //EJECUTAMOS LA CONSULTA Y GUARDAMOS EL RESULTADO EN UNA VARIABLE
29: $resPres = mysql_query($Presta);
30:
31: //GUARDAMOS EL NUEMRO DE FILAS EN OTRA VARIABLE
32: $total_presta = mysql_num_rows($resPres);
33:
34:
35: $ixx = 0;
36: while($datatmp = mysql_fetch_assoc($resPres)){
37: $ixx = $ixx+1;
38: $data[] = array_merge($datatmp, array('num'=>$ixx));
39: }
40: $titles = array(
41: 'id'=>'id',
42: 'usuario'=>'solicitante',
43: 'clave'=>'clave',
44: );
45: $options = array(
46: 'shadeCol'=>array(0.9,0.9,0.9),
47: 'xOrientation'=>'center',
48: 'width'=>500
49: );
50: $txttit = "Instituto Tecnológico de Los Mochisn";
51: $txttit.= "Reporte general de prestamos de edificiosn";
52:
53: $pdf->ezimage("escudo.jpg",0,150,'none','center');
54: $pdf->ezText($txttit, 12);
55: $pdf->ezTable($data, $titles, '', $options);
56: $pdf->ezText("nnn", 10);
57: $pdf->ezText("Fecha: ".date("d/m/Y"), 10);
58: $pdf->ezText("Hora: ".date("H:i:s")."nn", 10);
59: ob_end_clean();
60: $pdf->ezStream();
61: ?>
LES DEJO LAS LIBRERIAS Y CODIGOS FUENTE PARA QUE LO PUEDAN DESCARGAR, EN ESTE ENLACE ESTA TODO JUNTO CON EL EJEMPLO
DESCARGAR
EN ESTE ENLACE ESTA NOMAS LA LIBRERIA ORIGINAL PARA GENERAR EL PDF