Download the PHP package voilab/tctable without Composer
On this page you can find all versions of the php package voilab/tctable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package tctable
Voilab TcTable for TCPDF
Install
Via Composer
Create a composer.json file in your project root:
Usage
The goal of this library is not to replace a complex HTML table with row and cell spans. It's mainly useful if you want to display loads of lines (for an invoice, etc.) and be sure page breaks are in the right place. You can adapt the number of widow lines (minimum of lines that must appear on the last page), and use plugins to customize the flow (see below).
Basic usage
Plugins
Have a column that fit the remaining page width
Stripe rows
Widows management
Debug
The TcTable comes with a debug plugin tool that display datas passed in each event.
You can extend the printer object by creating your own:
Advanced plugin: draw a subtotal for a column at end of each page
We can go further by calculating a sum for a column, and display the current sum at the end of the page, and finally report it on the next page.
And the TcTable
Custom events
TcTable triggers some events we can listen to. Plugins use them a lot. But you can simply define events without the need of plugins. It allows us to add some usefull methods.
Add headers on each new page
Renderer and body functions
When parsing data, you can define either a renderer function for each or some columns, or an anonymous function when calling $tctable->addBody(). These functions are called twice, because it is needed in the process for height calculation. You need to take that into account in certain cases.
The same idea applies to column renderers.
Note In cases like the one above (creating a sum), you better should use plugins or events. With the event _TcTable::EV_ROWADDED, you can do exactely the same thing without bothering with height calculation (see below).
Optimizations
You can optimize the workflow if you know exactly the height of each row. You can bypass the height calculation this way:
If you want to change the way cell's height is calculated, you can override the default behaviour this way:
Remember that only multiline cells are checked for their height. The others aren't taken in the process.
Custom drawing function
If you need to insert images or need to do very specific things with cell's drawing, you can bypass the normal drawing function this way:
Testing
No test currently written...
Security
If you discover any security related issues, please use the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.