/** * Constructor * @param string $key the PDFLib license key we are using * @param int $pageType the type and size of the output */ public function __construct($key, $pageType, \Jazzee\Controller $controller) { $this->pdf = new \PDFlib(); if ($key) { try { $this->pdf->set_option("license={$key}"); } catch (PDFlibException $e) { throw new Exception("Unable to validate PDFLib license key, check that your PDFLib version is compatible with your key: " . $e->getMessage()); } } //This means we must check return values of load_font() etc. $this->pdf->set_option("errorpolicy=exception"); $this->pdf->set_option("hypertextencoding=unicode"); $this->fonts = array('h1' => array('face' => 'Helvetica-Bold', 'size' => '16.0', 'leading' => '100%', 'color' => array(207, 102, 0)), 'h3' => array('face' => 'Helvetica-Bold', 'size' => 12.0, 'leading' => '100%', 'color' => array(119, 153, 187)), 'h5' => array('face' => 'Helvetica-Bold', 'size' => 10.0, 'leading' => '100%', 'color' => array(119, 153, 187)), 'p' => array('face' => 'Helvetica', 'size' => 10.0, 'leading' => '100%', 'color' => array(0, 0, 0)), 'b' => array('face' => 'Helvetica-Bold', 'size' => 10.0, 'leading' => '100%', 'color' => array(0, 0, 0)), 'th' => array('face' => 'Helvetica-Bold', 'size' => 9.0, 'leading' => '100%', 'rowheight' => '10', 'color' => array(0, 0, 0)), 'td' => array('face' => 'Helvetica', 'size' => 8.0, 'leading' => '100%', 'rowheight' => '9', 'color' => array(0, 0, 0))); switch ($pageType) { case self::USLETTER_PORTRAIT: $this->pageWidth = 612; $this->pageHeight = 792; break; case self::USLETTER_LANDSCAPE: $this->pageWidth = 792; $this->pageHeight = 612; break; default: throw new Jazzee_Exception('Invalid page type supplied for ApplicantPDF constructor'); } // open new PDF file in memory $this->pdf->begin_document("", ""); //add the first page $this->pdf->begin_page_ext($this->pageWidth, $this->pageHeight, ""); $this->currentY = $this->pageHeight - 20; $this->setFont('p'); $this->pdf->set_info("Creator", "Jazzee"); $this->pdf->set_info("Author", "Jazzee Open Application Platform"); $this->currentText = $this->pdf->create_textflow('', ''); $this->_controller = $controller; }