Changing the default file name when using mPDF

I am currently using mPDF to create a pdf file from HTML (which was generated by PHP).

Everything works as expected, but I would like to be able to change the default file name. I currently have:

$payStub=new mPDF(); $payStub->SetTitle('My title'); $payStub->WriteHTML($pcTableRows); $payStub->Output(); 

When I save the pdf file that opens in my browser, it defaults to mpdf.pdf .
Can I change mpdf.pdf my choice?

I tried

 $payStub->Output('myFileName.pdf'); 

and

 $payStub->Output('myFileName.pdf', 'F'); 

but those who want to save it to the server, I try to use it when the user saves it locally.

+7
html php mpdf
source share
2 answers

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

 $payStub=new mPDF(); $payStub->SetTitle('My title'); $payStub->WriteHTML($pcTableRows); $payStub->Output('yourFileName.pdf', 'I'); 
+11
source share

Edit mdpdf.php

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

to download with a different name

-one
source share

All Articles