I'm trying to get a pdf generated by dompdf to download, so I wrote a function that returns dompdf's output, then I changed the headers of the page to include Content-type: application/pdf
, the only problem is for some reason is the response header is Content-type: text/html
anyways. It is a valid pdf file and everything, so I'm kind of at a loss as to why changing the content type isn't working.
public function couponDownload($location_uniqid = null) {
$this->autoRender = $this->layout = false;
// Set data
$account = $this->Account->getAccount($this->Auth->user('company_id'));
$data['Location'] = $account['Location'];
// Set headers
header('Content-type: application/pdf');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="coupon.pdf"');
header('Content-Transfer-Encoding: binary');
// Generate pdf
echo $this->Location->generateCouponPdf($data);
}