With mpdf, the following outputs the PDF inline to the browser:
$mpdf->Output();
How can I simply get the full URL of the created file? For example:
// http://example.com/tmp/file.pdf
$url = $mpdf->getURL();
With mpdf, the following outputs the PDF inline to the browser:
$mpdf->Output();
How can I simply get the full URL of the created file? For example:
// http://example.com/tmp/file.pdf
$url = $mpdf->getURL();
When outputting the file to the browser, the output file name is the file name of your script, no physical PDF file is being created and saved anywhere.
Therefore you could use something like
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
as answered in this QA.
Note that this cannot be used when you rely on HTTP POST method to generate the PDF.
If you need to save and provide static pdf file for later download, use F
(or helper constant \Mpdf\Output\Destination::FILE
in mPDF 7.x) output mode with path to desired file in the Output
method:
$filename = __DIR__ . '/download.pdf';
$mpdf->Output($filename, 'F');
You then have to create the URL to the file yourself as mPDF does not know anything (or care) about your domain, document root and path to the file-to-be-downloaded.
Also see documentation on the Output
method.