mPDF Manual – mPDF functions


(mPDF >= 1.0)

SetBasePath – Specifies a base URL for mPDF to interpret relative URLs


void SetBasePath ( string $url )

Specifies that mPDF should interpret any URLs in the HTML code relative to this $url. Otherwise relative paths will be based on the current script. This is important for hyperlinks, external stylesheets, and images.



A full URL should be provided, but the following will all work:



Example #1


$mpdf = new mPDF();

$url = "";

$html = file_get_contents($url);


// Now any relative paths e.g. <img src="../picture.jpg" /> will be parsed relative to a

   base path of ""