Name

draw_paragraph -- Paint a paragraph of text to a page

Synopsis

mixed draw_paragraph ( int top, int left, int bottom, int right, string text, int pageid[, array parameters] )

Description

This function paints a string of text on a page specified by pageid bounded by the rectangle specified by top, left, bottom, and right. The optional array parameters can be used to override the default text settings when placing the text.

See the documentation on the draw_text() function for details on default settings and the use of the parameters array.

Text is wrapped as needed to keep it within the boundries of the defined box. Newlines are preserved, so multiple paragraphs can be placed with a single command.

If the text string is too large to place in the alloted space, the text that could not be placed is returned. If the entire space is not filled, the value of bottom that would have been exactly filled is returned.

Examples

Assuming that $content is a large amount of text, the following lines will turn it into a PDF file, using as many pages as needed:

$pdf = new pdffile;
While (is_string($content)) {
    $page = $pdf->new_page("letter");
    $content = $pdf->draw_paragraph(720, 72, 72, 540, $content, $page);
}
echo $pdf->generate();

See Also

History

This function first appeared in version 1.14.

Bugs

Lines are wrapped at word boundries. If a single word is longer than the alloted space, it is placed on a line by itself.

This function (and the example shown above) are very ineffecient for converting very large files into PDF format. Use the alternate method described in draw_one_paragraph() instead.