Changing the default filename when using mPDF

前端 未结 3 1757
天命终不由人
天命终不由人 2021-01-03 23:56

I\'m currently using mPDF to generate a pdf from HTML (which was generated by PHP).

All works as expected but I\'d like to be able to change the default filename. C

相关标签:
3条回答
  • 2021-01-04 00:38

    Modify mdpdf.php

    form.setAttribute("action", "'._MPDF_URI.'includes/out.php/'.$name.'");
    

    for downloading with other name

    0 讨论(0)
  • 2021-01-04 00:45

    Try the I flag in the Output function, which will output the PDF to the browser, and use the filename from the first argument:

    $payStub=new mPDF();
    $payStub->SetTitle('My title');
    $payStub->WriteHTML($pcTableRows);
    $payStub->Output('yourFileName.pdf', 'I');
    
    0 讨论(0)
  • 2021-01-04 00:45

    You can try as:

    $file_name = 'yourFileName.pdf';
    $mpdf->Output($file_name, 'D');
    

    Help:

    1. 'D': download the PDF file
    2. 'I': serves in-line to the browser
    3. 'S': returns the PDF document as a string
    4. 'F': save as file $file_out
    0 讨论(0)
提交回复
热议问题