Record.php
<?php
if(isset($_POST['btn'])){
if(!isset($error)){
//create html of the data
ob_start();
?>
<?php
$body = ob_get_clean();
$body = iconv("UTF-8","UTF-8//IGNORE",$body);
include("mpdf/mpdf.php");
$mpdf=new \mPDF('c','A4','','' , 0, 0, 0, 0, 0, 0);
//write html to PDF
$mpdf->WriteHTML($body);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
$mpdf->WriteHTML(file_get_contents('Records.php'));
$mpdf->Output();
}
}
?>
I'm trying to make a pdf file of my current file. It has a table which data is fetching from database. The Problem is when i click on the button it redirects me to the pdf file but it gives me the error and the error is 'Failed to load PDF document'.You can see the error below.What am i doing wrong??
Make things simple:
<?php
include("mpdf/mpdf.php");
echo '<table border="1">';
echo '<tr><td>Put some content here!</td></tr>';
echo '</table>';
$html = ob_get_contents();
$filename = 'filename.pdf';
$mpdf = new mPDF('utf-8', 'A4-P');
$mpdf->WriteHTML($html);
$mpdf->Output($filename,'I');
Don't need to convert charset, this library is already running in UTF-8
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.