TCPDF : CellFitText

To be used with : TCPDF - PHP class for generating PDF documents.

Displays a cell containing text at the current position.

Provides control over borders, fill, padding, horizontal and vertical cell alignment, forced new lines and tabs.

Makes a prioritised set of compromises in an attempt to fit all the text within the cell. These compromises include reducing the font size, reducing cell padding, removing whitespace, removing forced new lines/tabs and splitting words. The set of compromises and the order they are applied can be controlled.

When to use

This script is most useful when placing variable length formatted text into fixed size page areas and ensuring that every effort is made to display all the text.

CellFitText.pdf   The documentation for the script is itself created using the CellFitText script.
Sample Code
TCPDF_CellFitText_documentation.php   The PHP code was used to create the above CellFitText.pdf example.
TCPDF_CellFitText.php   Version 1.0.0

1) Install TCPDF.

2) Copy the download code and save as TCPDF_CellfitText.php in the same directory that TCPDF.php is located.

3) When creating a new TCPDF object, refer to the object TCPDF_CellFitText rather than TCPDF.

   e.g.  $pdf = new TCPDF_CellFitText('P', 'mm', 'A4', true, 'UTF-8', false);

   The object TCPDF_CellFitText extends the object TCPDF, All the existing TCPDF functionality will be available as well as the new CellFitText method.

4) That's it! Good luck.