1. Go to this page and download the library: Download surda/mpdf library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
surda / mpdf example snippets
use Surda\Mpdf\MpdfFactory;
use Surda\Mpdf\Response\PdfResponse;
class OrderPresenter extends Nette\Application\UI\Presenter
{
/** @var MpdfFactory */
private $pdfFactory;
/**
* @param MpdfFactory $pdfFactory
*/
public function injectMpdfFactory(MpdfFactory $pdfFactory): void
{
$this->pdfFactory = $pdfFactory;
}
public function actionPdf(): void
{
$this->template->setFile('/path/to/template.latte');
$mpdf = $this->mpdfFactory->create();
$mpdf->WriteHTML($this->template);
$this->sendResponse(new PdfResponse($mpdf->Output()));
}
}