Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (48 sloc) 2.01 KB


MPDF library for TYPO3: 8.0.0

mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF with a number of enhancements. More:

Real life action controller function usage example

  • This example uses "t3helpers" extension for getting a template, parsed by fluid. Get t3helpers here:
  • This example demonstrates the use of an own ttf font
  • This example will protect the PDF (only readable)

Use "exit;" in your function, otherwise MAC/Safari users will not get a pdf file.

namespace Vendor\ExtensionName\Controller;

use Mpdf;

class DocumentsController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController

     * @param Project $project
     * @param Licencee $licencee
     * @return mixed
    public function documentAction(Project $project, Licencee $licencee)
        $licencenumber = 'MUGR-2728182721';
        $template = t3h::Template()->render(
            ['project' => $project, 'licencee' => $licencee, 'licencenumber' => $licencenumber]
        ob_clean(); // set to remove wrong headers which crashed some files (e.g. xls, dot, ...)
        /** @var \Mpdf\Mpdf $mpdf */
        $mpdf = new \Mpdf\Mpdf([
            'fontDir' => [
                PATH_typo3conf . 'ext/se_music_userarea/Resources/Private/Fonts',
            'fontdata' => [
                    'sfpro' => [
                        'R' => 'SF-Pro-Display-Regular.ttf',
                        'B' => 'SF-Pro-Display-Bold.ttf'
            'default_font' => 'sfpro'
        $mpdf->Output($licencenumber . '.pdf', Mpdf\Output\Destination::DOWNLOAD);

You can’t perform that action at this time.