TCPDF Multicell - Example 5 - Max Lines¶
Preview¶
Result pdf: ~
name~

example-multicell-5-max-lines.php¶
<?php
/**
* Pdf Advanced Multicell - Example
* Copyright (c), Interpid, http://www.interpid.eu
*/
require_once __DIR__ . '/../autoload.php';
use Interpid\PdfLib\Multicell;
use Interpid\PdfExamples\PdfFactory;
use Interpid\PdfExamples\PdfSettings;
$factory = new PdfFactory();
//get the PDF object
$pdf = PdfFactory::newPdf('multicell');
// Create the Advanced Multicell Object and inject the PDF object
$multicell = new Multicell($pdf);
// Set the styles for the advanced multicell
PdfSettings::setMulticellStyles($multicell);
$pdf->Ln(10); //line break
// create the advanced multicell
$title = file_get_contents(PDF_APPLICATION_PATH . '/content/multicell-title.txt');
$multicell->multiCell(0, 5, $title, 1, 'J', 1, 3, 3, 3, 3);
$pdf->Ln(10); //line break
//read TAG formatted text from file
$txt = file_get_contents(PDF_APPLICATION_PATH . '/content/multicell.txt');
$multicell->maxLines(7);
$multicell->multiCell(0, 5, $txt, 1, 'J', 1, 3, 3, 3, 3);
$pdf->Ln(10); //line break
$multicell->maxHeight(30);
$multicell->multiCell(0, 5, $txt, 1, 'J', 1, 3, 3, 3, 3);
// output the pdf
$pdf->Output();
multicell.txtmulticell.txt
<h3>Description:</h3>
<p>
This <b>TCPDF addon</b> allows creation of an <b>Advanced Multicell</b> which uses as input a <b>TAG based formatted string</b> instead of a simple string. The use of tags allows to change the font, the style (<b>bold</b>, <i>italic</i>, <u>underline</u>), the size, and the color of characters and many other features.
The call of the function is pretty similar to the Multicell function in the TCPDF base class with some extended parameters.
UTF8 characters are supported: <u8>¥ € ₡ ₢ ₤ ₥ ₦ ₧ ₩ ₪ ₫ ₭ ₮ ₯ ₹ Σ ε φ ά η</u8>
<h3>Features:</h3>
- Text can be <hh>aligned</hh>, <hh>centered</hh> or <hh>justified</hh>
- Different <font>Font</font>, <size>Sizes</size>, <style>Styles</style>, <color>Colors</color> can be used
- <u>Underline</u>, <s strike=''>Strikethrough</s>, <size strike='0.8'>Strikethrough line bold</size>
- The cell block can be framed and the background painted
- <style href='www.tcpdf.org'>Links</style> can be used in any tag
- <h4>TAB</h4> spaces (<b>\t</b>) can be used
- Variable Y relative positions can be used for <ss y='-0.8'>Subscript</ss> or <ss y='1.1'>Superscript</ss>
- Cell padding (left, right, top, bottom)
- Controlled Tag Sizes can be used
- <b>nowrap</b> can be used for a tag</p>
<size size='50' >Paragraph Example:~~~</size><font> - Paragraph 1</font>
<p size='60' > ~~~</p><font> - Paragraph 2</font>
<p size='60' > ~~~</p> - Paragraph 2
<p size='70' >Sample text~~~</p><p> - Paragraph 3</p>
<p size='50' >Sample text~~~</p> - Paragraph 1
<p size='60' > ~~~</p><h4> - Paragraph 2</h4>
<h3>Observations:</h3>
<p>
- If no <h4><TAG/></h4> is specified then the PDF current settings(font, style, size, color) are used
- The <h4>ttags</h4> tag name is reserved for the TAB SPACES
</p>
multicell-title.txtmulticell-title.txt
<h1>TCPDF Advanced Multicell</h1>