Example #1
0
 /**
  * Create a new page for drawing characters on; already contains title, selection circles, fold line and credits
  *
  * @return \SimplePdf\Page new page, with static info on it, but without characters
  */
 protected function createPage()
 {
     $page = new \SimplePdf\Page(\SimplePdf\Page::SIZE_A4, \SimplePdf\Page::UNITS_CENTIMETER);
     $page->setFont($this->getFont());
     $page->setMargins(0.8, 0.8, 2.0, 4.2);
     // Draw the title
     $page->setFontSize(12);
     $page->drawTextBlock($this->getTitle(), 0, \SimplePdf\Page::TEXT_ALIGN_RIGHT);
     // Draw the 2 selection circles
     $page->setLineWidth(1.0);
     for ($circleIndex = 0; $circleIndex < 2; $circleIndex++) {
         $page->drawCircle(0.6, $circleIndex * 2.5 + 1.8, 0.15, \SimplePdf\Page::SHAPE_DRAW_STROKE);
     }
     // Draw the fold line, together with the fold instruction and credits
     $page->setLineWidth(0.5);
     $page->setLineDashingPattern(array(10, 4));
     $page->drawLine(0, $page->getInnerHeight(), $page->getInnerWidth(), $page->getInnerHeight());
     $page->setLineDashingPattern(\SimplePdf\Page::LINE_DASHING_SOLID);
     $page->setFontSize(8);
     $page->drawTextBlock(' ' . $this->getFoldInstruction(), $page->getInnerHeight() + 0.1);
     $page->drawTextBlock($this->getCredits() . ' ', $page->getInnerHeight() + 0.1, \SimplePdf\Page::TEXT_ALIGN_RIGHT);
     return $page;
 }
Example #2
0
 * @copyright 2013 Robbert Klarenbeek
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 */
// Change this if you're not using Composer
require_once __DIR__ . '/../vendor/autoload.php';
if (!isset($argv[1])) {
    echo 'Usage: php ' . $argv[0] . ' <output-file>' . PHP_EOL;
    exit(1);
}
$file = $argv[1];
$pageSize = \SimplePdf\Page::SIZE_LETTER;
$units = \SimplePdf\Page::UNITS_INCH;
$pageMargin = 1.0;
// inch
$fontSize = 12;
$lineSpacing = 1.5;
$longText = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
// Use given $pageSize and $units, instead of the default A4 / centimeter
$page = new \SimplePdf\Page($pageSize, $units);
$page->setAllMargins($pageMargin);
// Draw rectangle marking the page margins
$page->setLineWidth(0.5);
$page->setLineDashingPattern(array(5, 3));
$page->drawRectangle(0, 0, $page->getInnerWidth(), $page->getInnerHeight(), \SimplePdf\Page::SHAPE_DRAW_STROKE);
// Write the long text, word-wrapped and aligned in the center of the page
$page->setFontSize($fontSize);
$page->setLineSpacing($lineSpacing);
$page->drawTextBlock($longText, 0, \SimplePdf\Page::TEXT_ALIGN_CENTER);
$pdf = new \ZendPdf\PdfDocument();
$pdf->pages[] = $page;
$pdf->save($file);