PDF_end_page($pdf); /* Output the current part of the in-memory created PDF document */ print PDF_get_buffer($pdf); } /* Create a DIN A4 page */ PDF_begin_page($pdf, 595, 842); return 812; } /* Create the first page */ $ypos = newpage(false); /* Split the example text into its lines */ $examplelines = split("\n", $exampletext); /* Make an instance of the class */ $text = new jh_pdf_flowingtext(&$pdf, &$ypos, 30, 565, 30); /* Set a function that will be called if a new page is necessary */ $text->setnewpagefunction(newpage); /* Set the font size */ $text->setfontsize(26); /* Loop through the lines of the example text */ foreach ($examplelines as $line) { if ($line != "") { /* If a line is non-empty, just feed it to the jh_pdf_flowingtext class */ $text->addtext($line, true); } else { /* If a line is empty, interpret it as end-of-paragraph: output the text and leave some empty space */ $text->putflowingtext(); $ypos -= 26; } }