-->

Dompdf — Error in php

2019-09-19 04:05发布

问题:

 %PDF-1.3
1 0 obj
<< /Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R >>
endobj
2 0 obj
<< /Type /Outlines /Count 0 >>
endobj
3 0 obj
<< /Type /Pages
/Kids [6 0 R
]
/Count 1
/Resources <<
/ProcSet 4 0 R
/Font << 
/F1 8 0 R
/F2 9 0 R
>>
>>
/MediaBox [0.000 0.000 612.000 792.000]
 >>
endobj
4 0 obj
[/PDF /Text ]
endobj
5 0 obj
<<
/Creator (DOMPDF)
/CreationDate (D:20150818031116-05'00')
/ModDate (D:20150818031116-05'00')
>>
endobj
6 0 obj
<< /Type /Page
/Parent 3 0 R
/Contents 7 0 R
>>
endobj
7 0 obj
<<
/Length 11727 >>
stream

When i use dompdf it gives me output like Above

My code is below

$dompdf = new DOMPDF();
$dompdf->load_html($_POST["data"]);
$pdf_name = "RPR".rand(0,99999);
//$dompdf->set_paper($_POST["paper"], $_POST["orientation"]);
$dompdf->render();
$pdf = $dompdf->output();
$file_location = "report/".$pdf_name.".pdf";
file_put_contents($file_location,$pdf);

$dompdf->stream("$pdf_name", array("Attachment" => false));

回答1:

I got the solution

Do something like that in demo.php:

if (@getimagesize($src)) {
      echo "0";
 }else{
      echo "<a href='$src' class='btn btn-purple'> Download Report <i class='fa fa-download'></i></a>";
 }
exit(0);


标签: php dompdf