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 the browser opens it in tab . But i want it not to open but auto download , My code is like follwing..
include("../mpdf.php"); $html="my HTML code here !"; $mpdf=new mPDF('c','A4','','',32,25,27,25,16,13); $mpdf->SetDisplayMode('fullpage'); $mpdf->list_indent_first_level = 0; $stylesheet = file_get_contents('mpdfstyletables.css'); $mpdf->WriteHTML($stylesheet,1); $mpdf->WriteHTML($html); $mpdf->Output('mpdf.pdf');
I am expecting that there will be a function to download in the mpdf class like $mpdf->download
instead $mpdf->Output('mpdf.pdf')
.I searched alot for this type solution but in vain i could't find any .
First, we need mPDF library to generate a PDF file. You can either download this from Github or install it using Composer. Let's know how to install the mPDF library using composer. Now, go to your project directory on the command prompt and run the following command to install mPDF library.
Online manual is available at https://mpdf.github.io/.
Find the PDF you want to open in your Files and double click to open. Select Adobe Acrobat (or whichever reader you downloaded) from the list of available options. If no list appears or the page opens in another application, you can right-click the file and select Open With to choose your PDF reader. Click Open.
2) Ensure all needed classes are loaded You can do this manually (reload, find the file with missing class, add require call, repeat) or you can use an autoloading library of your choice. Further usage is then the same as when using Composer, just require your autoloading script instead of Composer autoload.
Add 'D' parameter for download
$mpdf->Output('MyPDF.pdf', 'D');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With