Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Mpdf Port Bundle

Mpdf Port Bundle Laravel Package

tfox/mpdf-port-bundle

A Symfony bundle that integrates the mPDF library, providing service configuration and a straightforward way to generate PDFs from HTML in Symfony applications.

View on GitHub
Deep Wiki
Context7

A wrapper for mPDF class which allows to use mPDF in Symfony2 projects

Frequently asked questions about Mpdf Port Bundle
Can I install tfox/mpdf-port-bundle in a Laravel application?
No. It is a Symfony2 bundle, and Laravel has no bundle registration, services.yml autoloading, or DI extension lifecycle to consume it. Its Composer constraints target Symfony 2.x and PHP 5.x-era transitive requirements, so dependency resolution will fail against Laravel 10 or 11. It is also abandoned, Bitbucket-hosted, and has no PHP 8 compatibility or security response, so treat it as read-only reference material rather than a dependency.
What does tfox/mpdf-port-bundle actually do?
It is a thin dependency-injection wrapper that integrates the mPDF rendering library into Symfony. It registers mPDF through the service container and exposes bundle-level configuration for runtime options such as temp directories, font paths, and output settings. The actual PDF generation from HTML and CSS, including UTF-8 and multilingual content, is done entirely by mPDF itself.
How do I reimplement this bundle's pattern in Laravel?
Install the maintained upstream mpdf/mpdf package and recreate only the transferable idiom: a service provider that binds a configured renderer as a singleton, a config/pdf.php file for tempDir, fontDir, page format, and margins, and an interface such as PdfRenderer with a render method that accepts HTML and returns binary output. Inject the interface at call sites so application code never instantiates mPDF directly. That converts a future engine swap into a configuration change and typically takes one to three engineering days, with most effort going into CSS and font fidelity.
Which PHP and Laravel versions should I target for mPDF in Laravel?
Target PHP 8.2 or 8.3 and Laravel 10 or 11, and verify PHP 8 support explicitly on the current stable mpdf/mpdf release before it enters your lockfile. Run a security advisory check as part of that review. Do not rely on the bundle's original compatibility matrix, which reflects a PHP 5 and Symfony 2 era.
Is mPDF's GPLv2 licence a problem for a commercial Laravel SaaS?
mPDF is GPLv2 with a commercial licence available, so the licence must be cleared before code is written for SaaS or distributed products. The bundle wrapper does not change that obligation. Confirm with legal whether GPLv2 fits your distribution model or whether the commercial licence is required.
How do I configure mPDF tempDir, fontDir, and page size in Laravel?
Capture the bundle's config defaults for page size, margins, font paths, and temp-directory handling as a specification, then recreate them in config/pdf.php and pass them into the mPDF constructor. mPDF needs a writable temp directory and font cache outside the public webroot. Validate against your production fonts rather than defaults, because CJK and RTL fonts can add tens of megabytes per generated file.
How do I test PDF output after porting the pattern?
Use golden-file diff tests against known-good PDFs, plus assertions on page count, extracted text, and font rendering for multilingual content. Keep the renderer behind your PdfRenderer interface so tests can substitute a fake for call sites that only need to verify dispatch. For legacy Symfony2 output, run a behavioural port with the same inputs and compare results before switching over.
Should PDF generation be queued in Laravel?
Queue rendering from day one if documents exceed roughly ten pages or include images. Retrofitting asynchronous rendering later is materially more expensive than starting with a queued job that stores the output and returns a signed URL. Keep request-time rendering only for small, fast documents.
What are the security risks of rendering user-supplied HTML to PDF with mPDF?
mPDF renders attacker-influenceable HTML and may fetch remote resources referenced in that markup, and older versions carry known CVEs. Pin only the current upstream release, disable or allow-list remote image loading, and keep the temp directory outside the webroot. Treat any user-authored HTML as untrusted input and cap page counts and resource sizes.
What are alternatives to tfox/mpdf-port-bundle for PDF generation in Laravel?
Realistic options include upstream mpdf/mpdf behind your own renderer interface, dompdf, wkhtmltopdf wrappers such as laravel-snappy, headless Chrome via Browsershot, and Gotenberg as a separate service. Choose based on CSS fidelity, CJK and RTL support, and whether you need forms, encryption, signatures, PDF/A, or tagged accessibility output. Whichever you pick, bind it behind an interface rather than the concrete class.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console