- How do I install `voilab/tctable` in a Laravel project?
- Run `composer require voilab/tctable` and ensure TCPDF (`tecnickcom/tcpdf`) is installed. The package integrates seamlessly with Laravel’s service container, so no additional configuration is needed unless you’re using custom TCPDF settings.
- Does this package support Laravel 10?
- Yes, `voilab/tctable` is compatible with Laravel 10. However, verify TCPDF version compatibility (e.g., 6.5.x) in your `composer.json` to avoid conflicts. Test with your PHP version (8.1+) for edge cases.
- Can I use this for server-side pagination and sorting?
- No, this package focuses on **PDF table generation** with advanced page breaks, not web-based pagination. For web tables, pair it with Laravel Scout or a dedicated grid package like `yajra/laravel-datatables`.
- How do I handle large datasets (e.g., 50,000+ rows) without memory issues?
- Use TCPDF’s chunking via `setChunkSize()` in the package’s configuration. For extreme cases, pre-process data in batches or use Laravel Queues to generate PDFs asynchronously. Monitor memory with `memory_get_usage()`.
- Is there a way to customize table headers/footers or merge cells?
- Yes, extend the `TcTable` class or use TCPDF’s native methods like `Cell()` or `MultiCell()`. The package supports merged cells and custom headers/footers via TCPDF’s API—check the [TCPDF docs](https://tcpdf.org/) for advanced styling.
- Can I integrate this with Laravel Queues for background PDF generation?
- Absolutely. Dispatch a job (e.g., `GeneratePdfJob`) that uses `TcTable::render()` and stores the PDF in Laravel Storage. This is ideal for scaling to high-volume requests without blocking the web server.
- What are the alternatives if I don’t want to use TCPDF?
- For lightweight PDFs, consider `dompdf/dompdf` (simpler but less feature-rich). For advanced layouts, use TCPDF directly or explore `barryvdh/laravel-dompdf` (a DomPDF wrapper). However, `voilab/tctable` is TCPDF-centric and won’t work without it.
- How do I test PDF generation in CI/CD pipelines?
- Mock TCPDF’s file system operations (e.g., `Storage::fake()`) and assert PDF content using `PDF::setSourceFile()` or direct binary comparisons. Test edge cases like large datasets, Unicode text, and merged cells.
- Does this package support real-time data (e.g., live calculations) in tables?
- No, the package expects pre-fetched data (Eloquent collections or arrays). For real-time calculations, process data before passing it to `TcTable`—e.g., use Laravel Accessors or a service layer to compute aggregates.
- How do I serve generated PDFs to users (e.g., download or preview)?
- Use Laravel’s `Response::stream()` or `Storage::disk()->download()` to serve PDFs. For previews, embed the PDF in an `<iframe>` or use a library like `barryvdh/laravel-snappy` for HTML-to-PDF conversion if needed.