php - Save and download PDF -
i need 2 things & @ same time dompdf.
i need following - possible?
//print pdf file screen saving $dompdf->stream("pdf_filename_".rand(10,1000).".pdf", array("attachment" => false)); //save pdf file on server file_put_contents('/home/stsnew/public_html/pdf/file.pdf', $dompdf->output());
the above works fine if $dompdf->stream
, $dompdf->output()
done separately/individually , when try run them shown above, crashes.
any help/advice appreciated.
why dont swap them round create pdf first file , stream created file ?
$file_to_save = '/home/stsnew/public_html/pdf/file.pdf'; //save pdf file on server file_put_contents($file_to_save, $dompdf->output()); //print pdf file screen saving header('content-type: application/pdf'); header('content-disposition: inline; filename="file.pdf"'); header('content-transfer-encoding: binary'); header('content-length: ' . filesize($file_to_save)); header('accept-ranges: bytes'); readfile($file_to_save);
Comments
Post a Comment