Help with dompdf and variable assignment [closed]

0

This is the code that calls the pdf

 <a href="pdf.php" ><i class="glyphicon glyphicon-file">Descargar-PDF</i></a> 

and this is the pdf.php

<?php
require_once'dompdf/autoload.inc.php';
// Reference the Dompdf namespace
use Dompdf\Dompdf;

// Instantiate and use the dompdf class
$dompdf = new Dompdf();
// Load HTML content
$dompdf->loadHtml('  <table style="border-collapse: collapse;" border="1"; width="520"> 

        <tr>
            <td width="100"  rowspan="4">
                <p>
                    <img
                        width="100"
                        height="10"
                        src="file:///C:/Users/ASESOR~1/AppData/Local/Temp/msohtmlclip1/09/clip_image002.png"
                    />
                    <strong></strong>
                </p>
            </td>
            <td  height="18">
                <p align="center">
                 <font size=1>   PROCESO DE GESTIÓN DE RECURSOS</font>
                </p>
            </td>
            <td  height="18">
                <p align="center">
                   <font size=1> CÓDIGO
                </p>
            </td>
            <td  colspan="3"  height="10">
                <p align="center">
                  <font size=1>  FSW-100
                </p>
            </td>
        </tr>
        <tr>
            <td  height="18">
                <p align="center">
                   <font size=1> <strong>DEPARTAMENTO DE LAS TIC</strong>
                    <strong></strong>
                </p>
            </td>
            <td  rowspan="2"  height="10">
                <p align="center">
                   <font size=1> VERSIÓN 1
                </p>
            </td>
            <td  colspan="3" rowspan="2"  height="10">
                <p align="center">
                  <font size=1>  01-12-17
                </p>
            </td>
        </tr>
        <tr>
            <td  height="18">
                <p align="center">
                 <font size=1>   Tecnologías de la información y las comunicaciones
                </p>
            </td>
        </tr>
        <tr>
            <td  height="18">
                <p  align="center" >
                 <font size=2>   <strong>Acta de Entrega</strong></font>
                </p>
            </td>
            <td  height="18">
                <p align="center">
                <font size=1>    PAGINA
                </p>
            </td>
            <td  height="10">
                <p align="center">
                <font size=1>    1
                </p>
            </td>
            <td  height="18">
                <p align="center">
                <font size=1>    DE
                </p>
            </td>
            <td  height="18">
                <p align="center">
                  <font size=1>  2
                </p>
            </td>
        </tr>
    </tbody>
</table>   <font size=2> <table style="border-collapse: collapse; text-align: justify; margin-left: 4.8pt; margin-right: 4.8pt;" width="115">
<tbody>
<tr style="page-break-inside: avoid; height: 7.0pt;">
<td style="width: 519.25pt; border: none; border-bottom: solid windowtext 1.0pt; padding: 0cm 0cm 0cm 0cm; height: 7.0pt;" colspan="2" width="692">
<p><strong>Nombre del Usuario: </strong>MAYERLY ANGULO CORDOBA</p>
</td>
</tr>
<tr style="height: 7.4pt;">
<td style="width: 259.65pt; border: none; border-bottom: solid windowtext 1.0pt; padding: 0cm 0cm 0cm 0cm; height: 7.4pt;" width="346">
<p><strong>N&uacute;mero de Orden de Servicio:</strong> L070&nbsp;&nbsp;</p>
</td>
<td style="width: 259.55pt; border: none; border-bottom: solid windowtext 1.0pt; padding: 0cm 0cm 0cm 0cm; height: 7.4pt;" width="346">
<p><strong>Tel&eacute;fono:</strong> &nbsp;3232021532</p>
</td>
</tr>
<tr style="height: 6.4pt;">
<td style="width: 519.25pt; border: none; border-bottom: solid windowtext 1.0pt; padding: 0cm 0cm 0cm 0cm; height: 6.4pt;" colspan="2" width="692">
<p><strong>No. De Cedula:</strong> 1010212772 de Bogot&aacute;</p>
</td>
</tr>
</tbody>
</table>
</font>

<p  style="margin-top: 20px; line-height: normal;"><font size=2><strong>Herramientas</strong>: Se realiza entrega de computador port&aacute;til marca <strong>HP</strong> serie <strong>Pro desk 600 g1 sff</strong>, con n&uacute;mero de serial &nbsp;<strong>&nbsp;&nbsp;MXL4070KQW</strong>, con las siguientes caracter&iacute;sticas de hardware: procesador Intel core i5 6200u gen 6, memoria ram ddr 3 de 8 gb, disco duro de 500 gb de almacenamiento, pantalla antirreflejo de 21, color de equipo negro, con mouse de serial 674315-001 y teclado con serial 672646-163. se encuentra en un estado de <strong>usado</strong>.</p>

<p  style="margin-top: 20px; line-height: normal;"><font size=2><strong>Servicios:</strong> precargado con los siguiente software&acute;s: Windows 7 profesional, office 2016 home &amp; business, winrar, vlc, Skype, adobe reader, adatec para pc, Firefox, Chrome, plugins de navegaci&oacute;n, configuraciones, impresoras locales de oficinas swisslub, correo corporativo en pc y dispositivo m&oacute;vil, redes wifi y LAN.</p>

<p  style="margin-top: 20px; line-height: normal;"><font size=2>Usted como usuario asume la completa y total responsabilidad en caso de da&ntilde;o, perdida y deterioro del equipo entregado, fuera del deterioro normal con buen uso del equipo. <span style="color: black;">Este</span><span style="color: black; letter-spacing: 0pt;"> equipo es una estaci&oacute;n de trabajo que SWISSLUB S.A.S. est&aacute; poniendo a su disposici&oacute;n para uso dentro de sus oficinas; en caso31 de requerir trasladarlo quedar&aacute; bajo su riesgo y responsabilidad; esto quiere decir que, si el equipo sufre alg&uacute;n da&ntilde;o o perdida, usted deber&aacute; pagar el reemplazo del equipo, inmediatamente. Por lo cual, con su firma, a que los eventos detallados anteriormente, el valor del equipo le sea, descontado de n&oacute;mina o en caso de retiro de su liquidaci&oacute;n definitiva. Asimismo, el costo de reparaci&oacute;n o cambio de elemento da&ntilde;ado o perdido, siempre y cuando este da&ntilde;o no provenga del desgaste natural del equipo.</span></p>

<p style="margin-top: 20px; line-height: normal;"><font size=2> <span style="color: black; letter-spacing: 0pt;">La estaci&oacute;n de trabajo, solo funcionar&aacute; y deber&aacute; funcionar exclusivamente en el desarrollo de las actividades inherentes a su cargo. La informaci&oacute;n que se genere en el desarrollo de sus actividades como funcionario de la compa&ntilde;&iacute;a, estar&aacute;n alojadas en el equipo c&oacute;mputo perteneciente a <strong>SWISSLUB S.A.S.</strong>, prohibi&eacute;ndose su copiado y/o distribuci&oacute;n de las mismas a otros medios de almacenamiento, comunicaci&oacute;n a personas y segregaci&oacute;n de esta informaci&oacute;n; acorde a lo estipulado en la cl&aacute;usula segunda numeral dieciocho de sus obligaciones contractuales suscritas en su contrato de trabajo y reglamento interno de trabajo, articulo 45 numeral 1. De ninguna manera el equipo ser&aacute; utilizado para trabajo personal, almacenamiento de informaci&oacute;n personal y/o desarrollo recreativo; esta rotundamente prohibido la instalaci&oacute;n de software adicional sin autorizaci&oacute;n del Departamento de las TIC &ldquo;tecnolog&iacute;as de la informaci&oacute;n y la comunicaci&oacute;n&rdquo;; acorde a lo estipulado en la cl&aacute;usula segunda numeral diecisiete de sus obligaciones contractuales suscritas en su contrato de trabajo y reglamento interno de trabajo, articulo 45 numeral 9.</span></p>

<p  style="margin-top: 20px; line-height: normal;"><font size=2><span style="color: black; letter-spacing: 0pt;">Adicionalmente est&aacute; prohibido subir o bajar de Internet, m&uacute;sica y otros archivos ajenos al trabajo. Si el equipo muestra da&ntilde;o o mal funcionamiento por causa de archivos mal intencionados, y se encuentra m&uacute;sica o archivos ajenos al trabajo de la compa&ntilde;&iacute;a, los costos por reparaci&oacute;n y mantenimiento reinstalaci&oacute;n del sistema operativo y de los dem&aacute;s programas estar&aacute;n a su cargo.</span></p>

<p style="margin-top: 20px; text-align: justify;"><span style="font-size: 10.0pt;">Observaciones: </span></p>

<table style="border-collapse: collapse; margin-left: 4.8pt; margin-right: 4.8pt;" width="525">
<tbody>
<tr style="height: 6.2pt;">
<td style="width: 119.25pt; border: none; border-bottom: solid windowtext 1.0pt; padding: 0cm 0cm 0cm 0cm; height: 6.2pt;" width="192">
<p style="margin-bottom: .0001pt; line-height: normal;">&nbsp;</p>
</td>
</tr>
<tr style="height: 6.2pt;">
<td style="width: 100.25pt; border: none; border-bottom: solid windowtext 1.0pt; padding: 0cm 0cm 0cm 0cm; height: 6.2pt;" width="192">
<p style="margin-bottom: .0001pt; line-height: normal;">&nbsp;</p>
</td>
</tr>
</tbody>
</table>
</font>
   ');

// (Optional) Setup the paper size and orientation
$dompdf->setPaper( 'A4', 'portrait');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
$dompdf->stream();

?>

and I want it to be that way

    
asked by Kevin Salazar 27.10.2017 в 18:17
source

1 answer

2

As I said in one of the comments, the solution to the table that comes out of the margin of the sheet is to place the smaller text sizes and remove all the widths that you added to the td, this so that they have the freedom to adapt.

To send the data you need to be dynamic, you could send them by GET method in the following way:

 <a href="pdf.php?cedula=<?= $cedula ?>&nombre=<?= $nombre ?>" ><i class="glyphicon glyphicon-file">Descargar-PDF</i></a> 

So you can add the data you need to the url and in the pdf.php file you receive it in the following way:

<?php
require_once'dompdf/autoload.inc.php';
// Reference the Dompdf namespace
use Dompdf\Dompdf;

// Instantiate and use the dompdf class
$dompdf = new Dompdf();

$cedula = $_GET['cedula'];
$nombre= $_GET['nombre'];

And then only print them on the body of your pdf

 '<p><strong>Nombre del Usuario: </strong>'. $nombre .'</p>'

EXPLANATION REQUIRED

With the question mark (?) after pdf.php you are indicating that you are going to send variables using the get method, and with the sign (&) you are separating one variable from another.

    
answered by 27.10.2017 / 21:57
source