DOMPDF only rescues the html and not the data I get from the database

1

I need to extract to PDF the content HTML of a page inf_ev_003_7.php

The problem is that I only extract the HTML and not the data I get through SQL and PHP in this inf_ev_003_7.php

**así es mi código crearPdf.php:**

            <?php
                // Cargamos la librería dompdf que hemos instalado en la carpeta dompdf
                include("../../../config/lib/dompdf/autoload.inc.php");
                use Dompdf\Dompdf;

                ini_set('display_errors', 1);
                ini_set('display_startup_errors',1);
                error_reporting(E_ALL);

                $rut = $_GET['rut'];
                $ev  = $_GET['ev'];

                // Introducimos HTML de prueba



                 $html=file_get_contents_curl("http://localhost/inf_ev_003_7.php?ev='.$ev.'&rut='.$rut.'");

                echo $html;

                exit;

                // Instanciamos un objeto de la clase DOMPDF.
                $pdf = new DOMPDF();

                // Definimos el tamaño y orientación del papel que queremos.
                $pdf->set_paper("letter", "portrait");
                //$pdf->set_paper(array(0,0,104,250));

                // Cargamos el contenido HTML.
                $pdf->load_html(utf8_decode($html));

                // Renderizamos el documento PDF.
                $pdf->render();

                // Enviamos el fichero PDF al navegador.
                $pdf->stream('reporte_evaluacion2.pdf');


                function file_get_contents_curl($url) {
                    $crl = curl_init();
                    $timeout = 5;
                    curl_setopt($crl, CURLOPT_URL, $url);
                    curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
                    curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
                    $ret = curl_exec($crl);
                    curl_close($crl);
                    return $ret;
                }

I need to know what I'm missing or what I'm doing wrong, since I do not get the data rescued by sql and php of my page inf_ev_003_7.php in pdf .

    
asked by Francisco Acevedo 10.12.2018 в 02:57
source

1 answer

1

I managed to find a solution by replacing:

   $html=file_get_contents_curl("http://localhost/inf_ev_003_7.php?ev='.$ev.'&rut='.$rut.'");

by:

     ob_start();
     include 'inf_ev_003_7.php';
     $html = ob_get_clean();

I can not find another way to rescue the data using the URL, which apparently is the problem I had with 'file_get_contents_curl', with this correction I get the html and its complete data.

there are some alerts which do not interrupt its operation, but I would like to know what they should be:

 Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\config\config.php on line 4787

 Deprecated: Function session_register() is deprecated in C:\wamp\www\config\config.php on line 19

 Deprecated: Function session_register() is deprecated in C:\wamp\www\config\config.php on line 20
    
answered by 10.12.2018 / 03:53
source