Generar pdf con mpdf (error en tablas)
Publicado por Ramiro (20 intervenciones) el 25/05/2018 19:49:41
Hola gente, tengo el siguiente problema: es que al crear la tabla en el pdf no me agarra todos los registros. Aca les dejo los codigos a ver si alguien me dice en que me equivoco . Gracias.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
='editor_code'><?php
require_once('../../MPDF/mpdf.php');
require('../../Include/conexion.php');
$mpdf= new mPDF('c', 'A4');
$html=' <div class="main-container">
<table>
<thead>
<tr>
<th>Nombre</th>
<th>Apellido</th>
<th>Fecha de Nacimiento</th>
<th>Direccion</th>
<th>Contacto</th>
<th>Mascota</th>
</tr>
</thead>
';
$registro = mysql_query ("select * from personas as p
join clientes as cl
on p.id_personas = cl.id_duenos
join contacto as c
on c.id_contacto=p.id_contacto
join direccion as di
on di.id_direccion= p.id_direccion
join pacientes as pa
on pa.id_mascota = cl.id_mascotas",$conexion) or
die ("error SQL".mysql_error());
while($registro2 = mysql_fetch_array($registro)){
$html .='<tr>
<td>'.$registro2['nombre'].'</td>
<td>'.$registro2['apellido'].'</td>
<td>'.$registro2['fecha_nacimiento'].'</td>
<td>'.$registro2['calle'].''.$registro2['numero'].'</td>
<td>'.$registro2['celular'].'</td>
<td>'.$registro2['nombre_mas'].'</td>
</tr>
</table>
</div>
';
}
$css = file_get_contents('../../Css/pdf.css');
$mpdf->writeHTML($css, 1);
$mpdf->writeHTML($html);
$mpdf->Output('prueba.pdf','I');
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@charset "utf-8";
/* CSS Document */
.main-container{
width: 100%;
max-width: 600px;
}
table{
width: 100%;
text-align: left;
border-collapse: collapse;
background: #F5696B;
}
th, td{
border: solid 1px #000000;
padding: 10px;
}

Valora esta pregunta


0