0

Im using a simple pdf creater for php, basically its:

<?php
$html = "test";
inclued("MPDF57/mpdf.php");
$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
?>

If i run this, a pdf opens up with the text "test" in it.

Now my problem is, i want to out put a whole site, so im doing something like this on a separate file, its named printx.php. In side de file is code like this

<?php
$ID=$_GET['ID'];
$result=mysqli_query($link,"SELECT * FROM table WHERE ID = '$id');
?>
<html>
<table><tr><td>
<?php var_dump($result);?>
</td></tr></table>
</html>

there is a lot more, but it doesnt matter here, because if i call the site it self by 10.0.0.99/printx.php?ID=13 it works fine

if i do the following

 <?php
$html = require("printx.php?ID=13");
inclued("MPDF57/mpdf.php");
$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
?>

An empty site gets created as PDF

Why? What is the reason that the site does not got go into the pdf?

0

1 Answer 1

2

use $html = file_get_contents("printx.php?ID=13");

instead of $html = require("printx.php?ID=13");

Hmmm... file_get contents may require the full url so file_get_contents("http://10.0.0.99/printx.php?ID=13");

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.