I am trying to use the mpdf library to generate a pdf file and then send it directly to the client as a download, i.e. use the ‘D’ option in mpdf->Output - this gives an error message - see below. ( Alternatively i’d be happier using the ‘I’ option and send in line to the browser - but nothing appears to happen when i try this). using the ‘f’ option to generate a file works well.
I get a fatal error 'Data has already been sent to output, unable to output PDF file ’ . This problem is reported on the mpdf web site https://mpdf.github.io/troubleshooting/error-messages.html - i have followed the advice there but it hasn’t solved the problem.
with the following stack trace;
Fatal error : Uncaught Mpdf\MpdfException: Data has already been sent to output, unable to output PDF file in /var/www/test.homelesshealthlink.com/public_html/vendor/mpdf/mpdf/src/Mpdf.php:9543 Stack trace: #0
/var/www/test.homelesshealthlink.com/public_html/interface/forms/gad7/report.php(138): Mpdf\Mpdf->Output(‘gad796pdf’, ‘D’) #1
/var/www/test.homelesshealthlink.com/public_html/interface/forms/gad7/report.php(84): GeneratePDF(28, ‘96’) #2
/var/www/test.homelesshealthlink.com/public_html/interface/patient_file/encounter/forms.php(1103): gad7_report(28, 130, 2, ‘96’) #3
{main} thrown in /var/www/test.homelesshealthlink.com/public_html/vendor/mpdf/mpdf/src/Mpdf.php on line 9543
when i call ob_get_contents() it returns a string which is correctly displayed, calling ob_end_clean() does not help with the problem.
any help would be much appreciated, thanks ruth