From 9460b46e069e4607c561aeb572da1e04d1ce1afa Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 14 Dec 2025 09:06:38 +0000 Subject: [PATCH] Docs: add custom fonts configuration example Addresses #59 - shows how to configure fontDir, fontdata and default_font via mpdfConfig property. --- .docs/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.docs/README.md b/.docs/README.md index 8c17adc..af5b9d6 100644 --- a/.docs/README.md +++ b/.docs/README.md @@ -10,6 +10,7 @@ - [Force file to display in a browser](#force-file-to-display-in-a-browser) - [Set a pdf background easily](#set-a-pdf-background-easily) - [Create pdf with latte only](#create-pdf-with-latte-only) + - [Configuration of custom fonts for mPDF](#configuration-of-custom-fonts-for-mpdf) - [Configuration of custom temp dir for mPDF in PdfResponse](#configuration-of-custom-temp-dir-for-mpdf-in-pdfresponse) ## Usage @@ -155,6 +156,32 @@ public function actionPdf() } ``` +### Configuration of custom fonts for mPDF + +```php +use Contributte\PdfResponse\PdfResponse; + +public function actionPdf() +{ + $template = $this->createTemplate(); + $template->setFile(__DIR__ . "/path/to/template.latte"); + + $pdf = new PdfResponse($template); + $pdf->mpdfConfig = [ + 'fontDir' => [__DIR__ . '/fonts'], + 'fontdata' => [ + 'poppins' => [ + 'R' => 'Poppins-Regular.ttf', + 'B' => 'Poppins-Bold.ttf', + ], + ], + 'default_font' => 'poppins', + ]; + + $this->sendResponse($pdf); +} +``` + ### Configuration of custom temp dir for mPDF in PdfResponse ```neon