Name

wrap_text -- Break a text string into an array of lines

Synopsis

array wrap_text ( string string, float width[, array param])

Description

This function takes a text string and breaks it into an array of strings based on the width parameter. The resultant array is broken on word boundries and paragraph bounderies (newlines). The resultant array can be used to paint the string, line-by-line on the page.

When a single word is too long to fit on a line, a blank line is returned where that word would have existed, and the remainer of the string is processed as normal.

The param array is used to determine font and font size. If omitted, 12pt Helvetica is assumed.

Examples

Breaks the string $data into an array of strings, none of which will be greater than 200 PDF units wide when placed as 12 point Helvetica.

$strings = $pdf->wrap_text($data, 200);

See Also

History

The wrap_text() function was added in version 1.14

Bugs