Get external HTML code Render

1

I am putting together a PDF and in this PDF I have to put a graph that is being done by Highcharts . I created an HTML and JS code, and it is creating the right one, the problem is that I need to get the HTML code of this rendered graphic and when I make the request in the link of the page that mounts the graphic, it brings the HTML not rendered, that is , without running JS to mount the chart.

<?php

public function SendRequest($url){

        $curl_handle=curl_init();
        curl_setopt($curl_handle, CURLOPT_URL, $url);
        curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
        $query = curl_exec($curl_handle);
        curl_close($curl_handle);

        return $query;
}

public function cria_grafico($id_pedido, $id_produto){

     echo $this->load->view('sellins/GeraGraficoSellinB4', array('id_pedido'=>$id_pedido, 'id_produto'=>$id_produto), TRUE);

}

public function download($codigo_pedido = false){

$grafico = $this->SendRequest(base_url('Sellin_B4/cria_grafico/'.$produto['idPedido'].'/'.$produto['codigoProduto']));

$file = 'uploads/extract_sellin_goagro_'.time().'.pdf';

$mpdf = new mPDF();

$mpdf->SetHeader('Go Agro - Extract Sellin');

$mpdf->writeHTML($grafico);

$mpdf->SetFooter('{PAGENO}');

$mpdf->Output($file, 'F');

}

In the create_graphic method this is where it calls HTML with JS and mounts the chart. If I access the link miite.com.br/cria_grafico it shows the graphic rendered, but when I make a request to obtain the same result via code, it brings HTML without being rendered.

    
asked by anonymous 13.11.2017 / 17:48

1 answer

0

You will not be able to accomplish what you want because Javascript is ONLY executed on the client machine by the Web browser, after the client receives the content (and if Javascript is enabled).

Even when you try to make a request inside with cURL, it assembles everything and even puts the correct code, so when you access it, you see correctly because you see it from your browser. But internally the request is in the scope of the Web server, which when merging the view in the PDF does not interpret the Javascript code that truly mounts the graphic.

Try using a graphing library that uses only CSS. They are generally less beautiful and non-interactive, but they cater to situations like this.

    
17.11.2017 / 14:09