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
Tcpdf Laravel

Tcpdf Laravel Laravel Package

elibyy/tcpdf-laravel

elibyy/tcpdf-laravel is a Laravel wrapper for TCPDF that adds a service provider, facade, and publishable configuration. It simplifies generating, customizing, and outputting PDFs from Laravel apps, so you can stream, download, or save documents with minimal setup.

View on GitHub
Deep Wiki
Context7

TCPDF helper for laravel

Frequently asked questions about Tcpdf Laravel
How do I install elibyy/tcpdf-laravel in a Laravel app?
Install it with composer require elibyy/tcpdf-laravel. Laravel package auto-discovery registers the service provider and the TCPDF facade alias for you, so no manual bootstrapping is required. If you have disabled discovery, add the package's service provider and facade alias to config/app.php yourself. Optionally publish the config first so you can tune page format, margins, fonts, and metadata before generating your first document.
Which Laravel and PHP versions does tcpdf-laravel support?
The package is Composer-installable and is compatible with modern Laravel versions, targeting PHP 8.1 and newer stacks. TCPDF has a history of PHP 8.x deprecation notices and strict-mode warnings, so pin both the wrapper and TCPDF in composer.json and run your full test suite on the exact PHP minor you deploy. Treat deprecation output as a real signal, because it pollutes logs and can break strict error handlers.
How do I stream, download, or save a PDF with the TCPDF facade?
Build the document with TCPDF's normal methods on the facade, then call Output() with the destination you want: I for inline streaming to the browser, D for a download, F to write to disk, and S to return the raw string. In Laravel you typically wrap that in a response with the right Content-Type and filename. For saved files, write to a Storage disk path and serve through a signed route instead of exposing the filesystem directly.
How do I publish and customize config/tcpdf.php?
Run php artisan vendor:publish and choose the package's config tag to create config/tcpdf.php. From there you can set page format and units, margins, default font, encoding, and document metadata such as author and title. The config is bound into the container, so your changes apply the next time the facade resolves a TCPDF instance. Keep environment-specific values out of version control where you can.
Does tcpdf-laravel support modern HTML and CSS templates?
Only partially. TCPDF renders HTML through WriteHTMLCell and supports a subset of CSS 2.1 with no flexbox or grid, and table and page-break behavior can be inconsistent, so pixel parity with a browser view is not achievable. Templates from Dompdf, Snappy/wkhtmltopdf, or Browsershot will need rework. Also sanitize any user-controlled HTML before it reaches the renderer, since TCPDF resolves fonts, images, and links and can expose local-file and outbound-request risk; pair that with open_basedir and an allow-list.
How do I add custom fonts, headers, footers, or barcodes with this package?
These are TCPDF features, so you call TCPDF's own methods through the facade: register custom fonts with addTTFfont, override the Header() and Footer() methods on a subclass, and use write1DBarcode or write2DBarcode for barcodes. The wrapper deliberately adds no abstraction here, which keeps things simple but lets business logic drift toward TCPDF idioms. Put that logic in a dedicated PDF service or view model so controllers stay thin.
Is TCPDF's LGPL-3.0 license okay for a commercial Laravel application?
The Laravel wrapper is MIT, but TCPDF itself is LGPL-3.0. Unmodified library use is normally acceptable for commercial and on-prem products, but route it through legal review before it ships in distributed software. If you patch TCPDF core, the licensing calculus changes, so keep vendor code untouched and extend around it instead.
How do I test PDF generation in Laravel with this package?
Swap the facade for a mock and assert the calls you make — page setup, cells, and the Output destination — rather than trying to parse the resulting binary PDF. For files written to disk, use Storage::fake and assert the file exists and is non-empty. Also keep a small integration test that generates a real document on your target PHP version to catch TCPDF deprecation and strict-mode issues.
Should I generate large PDFs in a queued job instead of the request?
TCPDF generation is CPU and memory heavy and scales with document size, so long or large reports belong in a queued job rather than inside the web request. Store the finished file on a Storage disk, record the path on a model, and let the user download it once the job completes. Measure peak document sizes and generation volume first so you can size workers and set sensible timeouts.
Is elibyy/tcpdf-laravel still maintained, and what are the alternatives?
The wrapper is deliberately thin and low-activity, and TCPDF itself is in de facto maintenance mode, so treat this as a stable small adapter rather than a strategic platform bet. It is still a good fit when you need programmatic layout control, PDF/A, digital signatures, barcodes, or Unicode and RTL text. If you need HTML and CSS fidelity, evaluate Dompdf, mPDF, or a headless-Chrome renderer like Browsershot, and decide upfront who owns the fork if TCPDF stalls.
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.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect