imagestring($im, 5, 15, 75, 'A Simple Text String', $text_color); imagestring($im, 3, 25, 125, 'A Simple Text String', $text_color); imagestring($im, 2, 10, 155, 'A Simple Text String', $text_color); $content->appendImage($im); imagedestroy($im); $content->appendPageBreak(); for ($i = 0, $lenI = rand(10, 15); $i < $lenI; ++$i) { $content->appendChapterTitle($i + 1 . '. Chapter ' . ($i + 1)); for ($j = 0, $lenJ = rand(20, 40); $j < $lenJ; ++$j) { $content->appendParagraph('P' . ($i + 1) . '.' . ($j + 1) . ' TEXT TEXT TEXT'); } $content->appendPageBreak(); } $mobi->setContentProvider($content); //Get title and make it a 12 character long filename $title = $mobi->getTitle(); if ($title === false) { $title = 'file'; } $title = urlencode(str_replace(' ', '_', strtolower(substr($title, 0, 12)))); //Send the mobi file as download $mobi->download($title . '.mobi'); die; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Sample</title>