I create a pdf.php
<?php
include("mpdf60/mpdf.php");
$url = $_GET['url'];
ob_start();
include($url);
$html = ob_get_clean();
$mpdf=new mPDF('utf-8', 'A3-L');
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
?>
But when pass parameters exemple:
<?php
$url = 'gerencial_consad.php?mes='.$mes.'&ano='.$ano.'&menu=N';
?>
<a href="pdf.php?url=<?php echo $url; ?>">[ Gerar PDF ]</a>
The file PDF is create with the error:
Warning: include(gerencial_consad.php?mes=01): failed to open stream: Result too large in C:\wamp64\www\codforv2\pdf.php on line 7 Call Stack
1 0.0005 240264 {main}( ) ...\pdf.php: ( ! ) Warning: include(): Failed opening 'gerencial_consad.php?mes=01' for inclusion (include_path='.;C:\php\pear') in C:\wamp64\www\codforv2\pdf.php on line 7 Call Stack
1 0.0005 240264 {main}( ) ...\pdf.php:
Help me please!!!!
Thanks!
You don't want to include the URL, you want to download the contents of the URL with a HTTP client.
The simplest way, limited perhaps with allow_url_fopen
ini setting, is to use file_get_contents
function.
You need to pass the entire URL to the function:
$url = $_GET['url']; // http://example.com/
$html = file_get_contents($url);
$mpdf->WriteHTML($html);
Warning: by using unfiltered and unsanitized user input ($_GET['url']
directly), you are opening a security hole in your application. Always limit the input to content you know is safe.
You should best get only parameters for the URL from the request and combine the final URL internaly.