Auto download mpdf generated pdf document

后端 未结 2 1941
刺人心
刺人心 2021-01-01 10:16

I am newbie for mpdf so don\'t mind if you feel this question is stupid one:),

I generated the pdf document usinf mPDF class , the issue is that after pdf generated

相关标签:
2条回答
  • 2021-01-01 10:47

    Add 'D' parameter for download

    $mpdf->Output('MyPDF.pdf', 'D');
    
    0 讨论(0)
  • 2021-01-01 10:59

    for downloading use this

    $filename = "mpdf.pdf";
    if (file_exists($filename)) {
       header('Content-type: application/force-download');
       header('Content-Disposition: attachment; filename='.$filename);
       readfile($filename);
    }
    
    0 讨论(0)
提交回复
热议问题