an example to illustrate the use of pdf_show_boxed(...).
<?php
$pdf = pdf_new();
pdf_set_parameter($pdf,"license","xxxxxxx-xxxxxx-xxxxxx-xxxxxx"); pdf_set_info($pdf, "Creator", "pdf.php");
pdf_set_info($pdf, "Author", "hui");
pdf_open_file($pdf,""); pdf_begin_page($pdf,595,842); $font = pdf_findfont($pdf, "Helvetica", "host", 0);
$lineHeight = 10;
$y = 800;
pdf_setfont($pdf, $font, $lineHeight);
$text = "Hi, I am Hui.\n\rI am working in IT Dept.\nI am good at linux administration and programming in Java, PHP, Javascript, C and C++.";
$ret = pdf_show_boxed($pdf,$text,30,$y,350,$lineHeight,"left","");
$lineSpace = 5;
while($ret>0) {
$y = $y - $lineHeight-$lineSpace;
$left = substr($text,-$ret);
if($left[0] == "\n" or $left[0] == "\r") $left = substr($left,1); $ret = pdf_show_boxed($pdf,$left,30,$y,350,$lineHeight,"left","");
}
pdf_end_page($pdf);
pdf_close($pdf);
$buf = pdf_get_buffer($pdf);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=whatever.pdf");
print $buf;
?>
PS: Without "if" in the while loop, it will be an infinite loop when it encounters "\n" or "\r" in the text to be written.