- How do I install tecnickcom/tc-lib-pdf in a Laravel application?
- Install it with Composer using composer require tecnickcom/tc-lib-pdf. It is a pure-PHP library with no Laravel-specific dependencies, so it works alongside a standard Laravel Composer setup. You can use it directly in a controller, job, or custom service class.
- Is tc-lib-pdf compatible with Laravel 9 and Laravel 10?
- tc-lib-pdf is framework-agnostic and can be used with Laravel versions that support its required PHP version. The evaluation notes PHP 7.4 through 8.2 and Laravel 9/10 as the practical compatibility range to test. Always verify the current package requirements on Packagist before upgrading Laravel or PHP.
- Can tc-lib-pdf generate invoices, reports, certificates, and other dynamic PDFs in Laravel?
- Yes. It is designed for programmatic PDF generation, including invoices, reports, certificates, forms, tables, multi-column layouts, barcodes, and digital signatures. In Laravel, you typically pass database or Blade-derived data into a PDF service and stream or store the result. For complex layouts, it offers more control than lightweight HTML-to-PDF wrappers.
- How does tc-lib-pdf compare to barryvdh/laravel-dompdf for Laravel PDF generation?
- tc-lib-pdf is the modern successor to TCPDF and is mature, feature-rich, and battle-tested for complex PDF requirements. laravel-dompdf is often simpler for basic HTML-to-PDF output and has a more Laravel-first feel. Choose tc-lib-pdf when you need advanced layout control, Unicode support, encryption, signatures, barcodes, or other low-level PDF features.
- Do I need a Laravel service provider or wrapper to use tc-lib-pdf?
- No Laravel service provider is required because tc-lib-pdf is a standard Composer package. However, wrapping it in a PdfService class or service provider is a good way to centralize configuration, dependency injection, storage paths, and testability. This also isolates your application from future API changes.
- How do I configure page sizes, custom fonts, encryption, and digital signatures with tc-lib-pdf?
- These settings are configured through the library API and its companion packages rather than a Laravel config file. You set page dimensions, margins, fonts, encryption, and signature options while building the document or through your own wrapper configuration. For repeated settings, create an application-level PDF config and service class.
- Can I generate PDFs asynchronously with Laravel queues and tc-lib-pdf?
- Yes. Put PDF generation inside a Laravel job, pass the required data to the job, generate the document, and store it using Laravel's filesystem integration. This is useful for large reports, nightly batches, and high-volume output. Laravel Horizon can help monitor and scale queue workers.
- How should I test tc-lib-pdf PDF generation in Laravel?
- Test your wrapper or job rather than relying only on manual PDF inspection. Use PHPUnit or Pest with PDF snapshot assertions to verify layouts and output consistency, and assert that files are stored or responses are returned correctly. Keep fixtures for invoices, reports, and edge cases such as long text or missing fonts.
- Is tc-lib-pdf safe and performant enough for production PDF generation?
- It can be production-ready, but you should validate all dynamic content used in PDFs to prevent injection or unsafe embedded content. Benchmark memory and CPU usage for large documents, and move heavy generation to queue workers when needed. Add monitoring for failed jobs and consider checksums or validation for critical documents.
- Is tc-lib-pdf actively maintained, and how does it relate to TCPDF?
- tc-lib-pdf is presented as the modern, modular successor to TCPDF, which is now maintenance-only. The project uses a Composer-first workflow, strict PHP types, and companion packages for fonts, images, graphics, pages, encryption, and signatures. It is actively developed, and the maintainers ask companies that depend on it to sponsor ongoing maintenance.