I have implemented features to export report in pdf.
Following is the code:
$dompdf_config = new DOMPDF();
$template = new Template();
$template->data['products']=$results;
$html = $template->fetch('report/business_pdf.tpl');
$dompdf_config->load_html($html);
$dompdf_config->set_paper('letter', 'portrait');
$dompdf_config->render();
if (file_put_contents('report.pdf', $dompdf_config->output()) !== false) {
$this->redirect('report.pdf');
}
but it opens in browser,so how to force it to download?
Updated:
after that I have added code like:
$file = "report.pdf"
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
and getting download dialog like:
there is no open option in dialog,please help me