Unable to print pdf files from HTML by using DomPDF
I'm facing a problem with printing pdf files directly from html pages, for
this purpose i have used DomPDF plugin. all the required configuration
were made since i could not able to generate pdf documents.
NOTE : it will open a download window but the file doesn't contain
anything, just a pdf file & cannot be opened.. Adobe acrobat says "Acrobat
could not open '_20130818.pdf' because it is either not a supported file
type or because the file has been damaged"
This is my coding structure (View application page),
<a href="visa_application_pdf.php?id=<?php echo $visaid; ?>"> <button
name="visa_pdf">Print</button></a>
and the visa_application_pdf.php
<?php
if(isset($_GET['id']))
{
require_once ('dompdf/dompdf_config.inc.php');
$user_id = $_GET['id'];
require_once '../model/manage_visa.php';
$bookings = new Visa();
$result = $bookings->view_visa_bookings_byID($visaid);
$row = mysql_fetch_array($result);
ob_start();
?>
/// Page Content ///////////////////
<?php
}
else
{
echo "No Records";
}
$filename = $row['surname']."_".$row['nic_no'].date('Ymd');
$html = ob_get_contents();
ob_clean();
$dompdf = new DOMPDF();
$dompdf->set_paper("A4","portrait");
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream($filename.".pdf");
?>
No comments:
Post a Comment