Format a php report to be printable in pdf format using FDPF

0

It has the following report in php which I would like to give the format to be printable in FPDF

<?php
include 'conexion.php';
$proyecto=bd_rep1();
$alumno=bd_rep2();
$tutor=bd_rep3();
$alumnoi=bd_rep4();
$tutora=bd_rep5();
$asistema=bd_rep6();
$agas=bd_rep7();
$aeducacion=bd_rep8();
$aadministracion=bd_rep9();
$aagronoma=bd_rep10();
$aenfermeria=bd_rep11();
$proa=bd_rep12();
$prodesa=bd_rep13();
$proenpro=bd_rep14();
$prosis=bd_rep15();
$progas=bd_rep16();
$proedu=bd_rep17();
$proadm=bd_rep18();
$proagro=bd_rep19();
$proenf=bd_rep20();
$tutoraca=bd_rep21();
$tutorcomu=bd_rep22();
$tutormeto=bd_rep23();
$tutoresCarrera = bd_repxx();
?>

<h2>Reporte de Cantidades Generales</h2>
<table  class="table table-striped table-bordered table-hover">
<thead>
        <tr>
        <th><center>Proyectos</th>
        <th><center>Alumnos</th>
        <th><center>Tutores</th>
        <th><center>Alumnos Inscritos</th>
        <th><center>Tutores Asignados</th>
   </tr>
</thead>
<tbody>    
<tr>
        <td><?=$proyecto?></td>    
        <td><?=$alumno?></td>   
        <td><?=$tutor?></td>   
        <td><?=$alumnoi?></td> 
        <td><?=$tutora?></td> 
</tr>    
</tbody>
</table>

<h2>Reporte de Proyectos</h2>

<table  class="table table-striped table-bordered table-hover">
<thead>
        <tr>
        <th><center>Aprobados</th>
        <th><center>Desaprobados</th>
        <th><center>En Proceso</th>
        <th><center>Proyectos de Ing.Sistemas</th>
        <th><center>Proyectos de Ing.Gas</th>
        <th><center>Proyectos de Educación</th>
        <th><center>Proyectos de Administración</th>
        <th><center>Proyectos de Ing.Agronoma</th>
        <th><center>Proyectos de Enfermeria</th>
</tr>
</thead>
<tbody>    
<tr>

        <td><?=$proa?></td>    
        <td><?=$prodesa?></td> 
        <td><?=$proenpro?></td> 
    <td><?= $prosis?></td> 
<td><?=$progas?></td> 
<td><?=$proedu?></td> 
<td><?=$proadm?></td> 
<td><?=$proagro?></td> 
<td><?=$proenf?></td> 

            </tr>    
</tbody>
</table>

<h2>Reporte de Alumnos</h2>

<table  class="table table-striped table-bordered table-hover">
<thead>
        <tr>
                <th><center>Alumnos en Ing.Sistemas</th>
        <th><center>Alumnos en Ing.Gas</th>
        <th><center>Alumnos en Educación</th>
        <th><center>Alumnos en Administración</th>
        <th><center>Alumnos en Ing.Agronoma</th>
        <th><center>Alumnos en Enfermeria</th>
</tr>
</thead>
<tbody>    
<tr>

                   <td><?=$asistema?></td> 
        <td><?=$agas?></td> 
        <td><?=$aeducacion?></td> 
        <td><?=$aadministracion?></td> 
        <td><?=$aagronoma?></td> 
        <td><?=$aenfermeria?></td> 
                  </tr>    
</tbody>
</table>

<h2>Reporte de Tutores</h2>

<table  class="table table-striped table-bordered table-hover">
<thead>
        <tr>
             <th><center>Tutores Academicos</th>
        <th><center>Tutores Comunitario</th>
        <th><center>Tutores Metodológico</th>
        <th><center>Tutores en Ing.Sistemas</th>
        <th><center>Tutores en Ing.Gas</th>
        <th><center>Tutores en Educación</th>
        <th><center>Tutores en Administración</th>
        <th><center>Tutores en Ing.Agronoma</th>
        <th><center>Tutores en Enfermería</th>
</tr>
</thead>
<tbody>    
<tr>

        <td><?=$tutoraca?></td> 
        <td><?=$tutorcomu?></td> 
        <td><?=$tutormeto?></td> 
<?php
    foreach ($tutoresCarrera as &$fila) {
        echo '<td>' . $fila['cant'] . '</td>';
    } 
?>
</tbody>  
</tbody>
</table>

It is necessary to pass all the data to CELL, and return the values to each data, as this example shows: " link "

On the other hand, how feasible is the option of printing the screen with javascript:

"print" button:

    '<input name="btnImprimir" id="btnImprimir" type="button" class="button" value="Imprimir" onClick="imprime()">'

"Print function":

    'function imprime(){
    //desaparece el boton
    document.getElementById("btnImprimir").style.display='none'
    //se imprime la pagina
    window.print()
    //reaparece el boton
    document.getElementById("btnImprimir").style.display='inline'
    }'
    
asked by Victor Alejandro Alvarado Vilo 09.09.2016 в 21:57
source

1 answer

1

I almost solved it using the code I added, but it's simple to take a photo and save it in pdf format, with the Window.print.

In javascripts I created the "print" button:

'<input name="btnImprimir" id="btnImprimir" type="button" class="button" value="Imprimir" onClick="imprime()">'

and in a Js file the function print (print.js)

function imprime(){
//desaparece el boton
document.getElementById("btnImprimir").style.display='none'
//se imprime la pagina
window.print()
//reaparece el boton
document.getElementById("btnImprimir").style.display='inline'
}

Then I include it in the document

<script src="imprimir.js" type="text/javascript"></script>
  • Although the format quality you get is not very good as they are forms that do not fit full on a sheet

  • Second that you do not export yourself unless you're in a browser like mozilla

answered by 09.09.2016 в 22:58