Take the 2-minute tour ×

I have a page which uses mPDF and when you run its displays as a PDF in the browser, it can also be saved from here as a PDF no problem. What I would like to happen is when the page is run and generates a PDF that the page is saved as a PDF on the server.

Here is the current code:

include $_SERVER['DOCUMENT_ROOT'].'/include/seo-check/lib/WSAclient.php';
include $_SERVER['DOCUMENT_ROOT'].'/include/seo-check/lib/WSAParser.php';

$reportID= $_GET['reportid'];

$WSAclient = new WSAclient(WSA_USER_ID,WSA_API_KEY);



<title>PDF Report</title>
<!--Add your CSS here-->
echo WSAParser::viewReportResponse($result);
$HTMLoutput = ob_get_contents();

//Convert HTML 2 PDF by using MPDF PHP library
include $_SERVER['DOCUMENT_ROOT'].'/include/seo-check/lib/MPDF/mpdf.php';
$mpdf=new mPDF(); 


Like I said this outputs the PDF fine but could someone tell me how to save as a PDF??


share|improve this question
add comment

2 Answers

up vote 17 down vote accepted

Docs state that the first argument of Output() is the file path, second is the savng mode - you need to set it to 'F'.

share|improve this answer
You my friend are a life saver, spent hours trying to find that. Thank you! –  Paul Sep 24 '12 at 23:28
This didn't work for me, but changing it to D instead of F did! What do they mean? –  Mikeys4u Jan 16 at 9:20
D - send to browser and force download, F - save to file. Docs link I provided explains it. –  Sergey Eremin Jan 16 at 10:59
add comment

for me, worked this:


but some people claimed about an issue here - http://mpdf.bpm1.com/forum/comments.php?DiscussionID=123

share|improve this answer
add comment

Your Answer


