Пример #1
0
 /**
  * Creates a PDF report from the Minutes model given.
  * Returns the PDF as a string that can either be saved to disk
  * or streamed back to the browser.
  *
  * @param Phprojekt_Model_Interface $minutesModel The minutes model object to create the PDF from.
  *
  * @return string The resulting PDF document.
  */
 public static function getPdf(Phprojekt_Model_Interface $minutesModel)
 {
     $phpr = Phprojekt::getInstance();
     $pdf = new Zend_Pdf();
     $page = new Phprojekt_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
     $pages = array($page);
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
     $page->setBorder(2.0 * Phprojekt_Pdf_Page::PT_PER_CM, 2.0 * Phprojekt_Pdf_Page::PT_PER_CM, 2.0 * Phprojekt_Pdf_Page::PT_PER_CM, 3.0 * Phprojekt_Pdf_Page::PT_PER_CM);
     $page->addFreetext(array('lines' => $minutesModel->title, 'fontSize' => 20));
     $page->addFreetext(array('lines' => array_merge(explode("\n\n", $minutesModel->description), array($phpr->translate('Start') . ': ' . $minutesModel->meetingDatetime, $phpr->translate('End') . ': ' . $minutesModel->endTime, $phpr->translate('Place') . ': ' . $minutesModel->place, $phpr->translate('Moderator') . ': ' . $minutesModel->moderator)), 'fontSize' => 12));
     $invited = Minutes_Helpers_Userlist::expandIdList($minutesModel->participantsInvited);
     $attending = Minutes_Helpers_Userlist::expandIdList($minutesModel->participantsAttending);
     $excused = Minutes_Helpers_Userlist::expandIdList($minutesModel->participantsExcused);
     $pages += $page->addTable(array('fontSize' => 12, 'rows' => array(array(array('text' => $phpr->translate('Invited'), 'width' => 4.7 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => array_reduce($invited, array('self', '_concat')), 'width' => 12.0 * Phprojekt_Pdf_Page::PT_PER_CM)), array(array('text' => $phpr->translate('Attending'), 'width' => 4.7 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => array_reduce($attending, array('self', '_concat')), 'width' => 12.0 * Phprojekt_Pdf_Page::PT_PER_CM)), array(array('text' => $phpr->translate('Excused'), 'width' => 4.7 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => array_reduce($excused, array('self', '_concat')), 'width' => 12.0 * Phprojekt_Pdf_Page::PT_PER_CM)))));
     $page = end($pages);
     $itemtable = array();
     $items = $minutesModel->items->fetchAll();
     foreach ($items as $item) {
         $itemtable[] = array(array('text' => $item->topicId, 'width' => 1.3 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $phpr->translate($item->information->getTopicType($item->topicType)), 'width' => 3.0 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $item->getDisplay(), 'width' => 12.4 * Phprojekt_Pdf_Page::PT_PER_CM));
     }
     $pages += $page->addTable(array('fontSize' => 12, 'rows' => array_merge(array(array('isHeader' => true, array('text' => $phpr->translate('No.'), 'width' => 1.3 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $phpr->translate('Type'), 'width' => 3.0 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $phpr->translate('Item'), 'width' => 12.4 * Phprojekt_Pdf_Page::PT_PER_CM))), $itemtable)));
     $page = end($pages);
     $pdf->pages = $pages;
     $pdf->properties['Title'] = $minutesModel->title;
     $owner = Minutes_Helpers_Userlist::expandIdList($minutesModel->ownerId);
     $pdf->properties['Author'] = $owner[0]['display'];
     $pdf->properties['Producer'] = 'PHProjekt version ' . Phprojekt::getVersion();
     $pdf->properties['CreationDate'] = 'D:' . gmdate('YmdHis');
     $pdf->properties['Keywords'] = $minutesModel->description;
     return $pdf->render();
 }
Пример #2
0
 public function testDrawing()
 {
     $pdf = new Zend_Pdf();
     // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
     $pdf->pages[] = $page1 = $pdf->newPage('A4');
     // Add new page generated by Zend_Pdf_Page object (page is not attached to the document)
     $pdf->pages[] = $page2 = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE);
     // Create new font
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     // Apply font and draw text
     $page1->setFont($font, 36);
     $page1->setFillColor(Zend_Pdf_Color_Html::color('#9999cc'));
     $page1->drawText('Helvetica 36 text string', 60, 500);
     // Use font object for another page
     $page2->setFont($font, 24);
     $page2->drawText('Helvetica 24 text string', 60, 500);
     // Use another font
     $page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32);
     $page2->drawText('Times-Roman 32 text string', 60, 450);
     // Draw rectangle
     $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8));
     $page2->setLineColor(new Zend_Pdf_Color_GrayScale(0.2));
     $page2->setLineDashingPattern(array(3, 2, 3, 4), 1.6);
     $page2->drawRectangle(60, 400, 400, 350);
     // Draw circle
     $page2->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID);
     $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     $page2->drawCircle(85, 375, 25);
     // Draw sectors
     $page2->drawCircle(200, 375, 25, 2 * M_PI / 3, -M_PI / 6);
     $page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0));
     $page2->drawCircle(200, 375, 25, M_PI / 6, 2 * M_PI / 3);
     $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0));
     $page2->drawCircle(200, 375, 25, -M_PI / 6, M_PI / 6);
     // Draw ellipse
     $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     $page2->drawEllipse(250, 400, 400, 350);
     $page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0));
     $page2->drawEllipse(250, 400, 400, 350, M_PI / 6, 2 * M_PI / 3);
     $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0));
     $page2->drawEllipse(250, 400, 400, 350, -M_PI / 6, M_PI / 6);
     // Draw and fill polygon
     $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1));
     $x = array();
     $y = array();
     for ($count = 0; $count < 8; $count++) {
         $x[] = 140 + 25 * cos(3 * M_PI_4 * $count);
         $y[] = 375 + 25 * sin(3 * M_PI_4 * $count);
     }
     $page2->drawPolygon($x, $y, Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, Zend_Pdf_Page::FILL_METHOD_EVEN_ODD);
     // Draw line
     $page2->setLineWidth(0.5);
     $page2->drawLine(60, 375, 400, 375);
     $pdf->save(dirname(__FILE__) . '/_files/output.pdf');
     unset($pdf);
     $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
     $this->assertTrue($pdf1 instanceof Zend_Pdf);
     unset($pdf1);
     unlink(dirname(__FILE__) . '/_files/output.pdf');
 }
Пример #3
0
 public function getWrappedText($string, $max_width, $font = '', $fontsize = 14)
 {
     $font = Zend_Pdf_Font::fontWithName($font);
     $wrappedText = '';
     $nLines = 1;
     $lines = explode("\n", $string);
     foreach ($lines as $line) {
         $words = explode(' ', $line);
         $word_count = count($words);
         $i = 0;
         $wrappedLine = '';
         while ($i < $word_count) {
             /* if adding a new word isn't wider than $max_width,
                we add the word */
             if ($this->widthForStringUsingFontSize($wrappedLine . ' ' . $words[$i], $font, $fontsize) < $max_width) {
                 if (!empty($wrappedLine)) {
                     $wrappedLine .= ' ';
                 }
                 $wrappedLine .= $words[$i];
             } else {
                 $wrappedText .= $wrappedLine . "\n";
                 $nLines++;
                 $wrappedLine = $words[$i];
             }
             $i++;
         }
         $wrappedText .= $wrappedLine . "\n";
     }
     return array('text' => $wrappedText, 'n' => $nLines);
 }
 public function process()
 {
     $configuracao = Doctrine::getTable('Configuracao')->find(1);
     $this->document->pages[] = $page = $this->document->newPage(\Zend_Pdf_Page::SIZE_A4);
     //monta o cabecalho
     $color = array();
     $color["black"] = new Zend_Pdf_Color_Html("#000000");
     $fontTitle = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $size = 12;
     $styleTitle = new Zend_Pdf_Style();
     $styleTitle->setFont($fontTitle, $size);
     $styleTitle->setFillColor($color["black"]);
     $page->setStyle($styleTitle);
     $page->drawText($configuracao->instituicao, Documento::DOCUMENT_LEFT, Documento::DOCUMENT_TOP, 'UTF-8');
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
     $style = new Zend_Pdf_Style();
     $style->setFont($font, $size);
     $style->setFillColor($color["black"]);
     $page->setStyle($style);
     $text = wordwrap($this->text, 95, "\n", false);
     $token = strtok($text, "\n");
     $y = 665;
     while ($token != false) {
         if ($y < 100) {
             $this->document->pages[] = $page = $this->document->newPage(Zend_Pdf_Page::SIZE_A4);
             $page->setStyle($style);
             $y = 665;
         } else {
             $y -= 15;
         }
         $page->drawText($token, 60, $y, 'UTF-8');
         $token = strtok("\n");
     }
 }
Пример #5
0
 public function verPdfAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $producto = $this->_producto->getDetalle($this->_getParam('id'));
     //        var_dump($producto);exit;
     $pdf = new Zend_Pdf();
     $pdf1 = Zend_Pdf::load(APPLICATION_PATH . '/../templates/producto.pdf');
     //        $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4); // 595 x842
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     //        $pdf->pages[] = $page;
     //        $page->setFont($font, 20);$page->drawText('Zend: PDF', 10, 822);
     //        $page->setFont($font, 12);$page->drawText('Comentarios', 10, 802);
     //        $pdfData = $pdf->render();
     $page = $pdf1->pages[0];
     $page->setFont($font, 12);
     $page->drawText($producto['producto'], 116, 639);
     $page->drawText($producto['precio'], 116, 607);
     $page->drawText($producto['categoria'], 116, 575);
     $page->drawText($producto['fabricante'], 116, 543);
     $page->drawText('zEND', 200, 200);
     $pdfData = $pdf1->render();
     header("Content-type: application/x-pdf");
     header("Content-Disposition: inline; filename=result.pdf");
     $this->_response->appendBody($pdfData);
 }
Пример #6
0
 protected function _setFontItalic($object, $size = 7)
 {
     if (!$this->getUseFont()) {
         return parent::_setFontItalic($object, $size);
     }
     $font = Zend_Pdf_Font::fontWithName(constant('Zend_Pdf_Font::FONT_' . $this->getUseFont() . '_ITALIC'));
     $object->setFont($font, $size);
     return $font;
 }
Пример #7
0
 /**
  * Object constructor
  *
  * @param string $fontName
  * @throws Zend_Pdf_Exception
  */
 public function __construct($fontName)
 {
     if (!in_array($fontName, Zend_Pdf_Const::$standardFonts)) {
         throw new Zend_Pdf_Exception('Wrong font name');
     }
     parent::__construct();
     $this->_resource->Subtype = new Zend_Pdf_Element_Name('Type1');
     $this->_resource->BaseFont = new Zend_Pdf_Element_Name($fontName);
 }
Пример #8
0
 public function setStyle()
 {
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
     $style->setFillColor(new Zend_Pdf_Color_Html('#333333'));
     $style->setLineColor(new Zend_Pdf_Color_Html('#990033'));
     $style->setLineWidth(1);
     $this->_page->setStyle($style);
 }
Пример #9
0
 public static function get($font)
 {
     if (empty(Fonts::$loaded[$font])) {
         if (!isset(Fonts::$fonts[$font])) {
             exit('NO FONT SELECTED');
         }
         Fonts::$loaded[$font] = Zend_Pdf_Font::fontWithPath("__fonts/" . Fonts::$fonts[$font]);
     }
     return Fonts::$loaded[$font];
 }
Пример #10
0
 public function __construct()
 {
     $this->_page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
     $this->_yPosition = 60;
     $this->_leftMargin = 50;
     $this->_pageHeight = $this->_page->getHeight();
     $this->_pageWidth = $this->_page->getWidth();
     $this->_normalFont = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $this->_boldFont = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
 }
Пример #11
0
 protected function _buildPDFDocuments(Doc_Book $book)
 {
     set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../_vendor/zf');
     $pdf = new Zend_Pdf();
     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     $font = Zend_Pdf_Font::fontWithPath('c:\\windows\\fonts\\simkai.ttf');
     $page->setFont($font, 12);
     $pdf->pages[] = $page;
     $page->drawText('中文测试', 100, 430, 'UTF-8');
     $pdf->save('output.pdf');
 }
Пример #12
0
 /**
  * Generates the signup sheet for the given event
  * 
  * @param $event
  */
 public function generateSignupSheet($event)
 {
     /**
      * Calculate how many pages are needed
      */
     $entriesPerPage = 37;
     $pageCount = ceil(count($event['attendeeList']) / $entriesPerPage);
     /*
      * Set up the offsets for the three columns (first, last, signature)
      */
     $this->_offsets['columnLeft'] = 45;
     $this->_offsets['columnMiddle'] = 150;
     $this->_offsets['columnRight'] = 250;
     /**
      * Fill each page with user information
      */
     for ($i = 0; $i < $pageCount; $i++) {
         $page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
         $this->_pdf->pages[] = $page;
         $lineCounter = 0;
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 9);
         $page->drawText('Page ' . ($i + 1) . ' of ' . $pageCount, $this->_offsets['right'] - 40, $this->_offsets['top']);
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12);
         $page->drawText($event['workshopTitle'], $this->center($event['workshopTitle']), $this->getLineOffset($lineCounter++));
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
         $page->drawText($event['location'], $this->center($event['location']), $this->getLineOffset($lineCounter++));
         $date = new DateTime($event['date']);
         $startTime = new DateTime($event['startTime']);
         $endTime = new DateTime($event['endTime']);
         $dateString = $date->format('l, M d, Y') . '(' . $startTime->format('g:i A') . ' - ' . $endTime->format('g:i A') . ')';
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
         $page->drawText($dateString, $this->center($dateString), $this->getLineOffset($lineCounter++));
         $instructorString = 'Instructor' . (count($event['instructors']) > 1 ? 's' : '') . ': ' . implode(', ', $event['instructors']);
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
         $page->drawText($instructorString, $this->center($instructorString), $this->getLineOffset($lineCounter++));
         $lineCounter += 2;
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12);
         $page->drawText('First Name', $this->_offsets['columnLeft'], $this->getLineOffset($lineCounter));
         $page->drawText('Last Name', $this->_offsets['columnMiddle'], $this->getLineOffset($lineCounter));
         $page->drawText('Signature', $this->_offsets['columnRight'], $this->getLineOffset($lineCounter));
         $lineCounter++;
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
         $attendeeList = array_slice($event['attendeeList'], $i * $entriesPerPage, $entriesPerPage);
         foreach ($attendeeList as $a) {
             $page->drawText($a['firstName'], $this->_offsets['columnLeft'], $this->getLineOffset($lineCounter));
             $page->drawText($a['lastName'], $this->_offsets['columnMiddle'], $this->getLineOffset($lineCounter));
             $page->drawLine($this->_offsets['columnRight'], $this->getLineOffset($lineCounter) - 2, $this->_offsets['right'], $this->getLineOffset($lineCounter) - 2);
             $lineCounter++;
         }
     }
     return $this->_pdf->render();
 }
Пример #13
0
 function stringWidth($string, $fontName = PdfContext::fontHelvetica, $fontSize = 12)
 {
     $font = Zend_Pdf_Font::fontWithName($fontName);
     $drawingString = iconv('', 'UTF-16BE', $string);
     $characters = array();
     for ($i = 0; $i < strlen($drawingString); $i++) {
         $characters[] = ord($drawingString[$i++]) << 8 | ord($drawingString[$i]);
     }
     $glyphs = $font->cmap->glyphNumbersForCharacters($characters);
     $widths = $font->widthsForGlyphs($glyphs);
     $stringWidth = array_sum($widths) / $font->getUnitsPerEm() * $fontSize;
     return $stringWidth;
 }
 /**
  * Dessine l'entete du tableau avec la liste des produits
  *
  * @param unknown_type $page
  */
 public function drawTableHeader(&$page)
 {
     //entetes de colonnes
     $this->y -= 15;
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
     $page->drawText(mage::helper('purchase')->__('Qty'), 15, $this->y, 'UTF-8');
     $page->drawText(mage::helper('purchase')->__('Manufacturer'), 70, $this->y, 'UTF-8');
     $page->drawText(mage::helper('purchase')->__('Sku'), 180, $this->y, 'UTF-8');
     $page->drawText(mage::helper('purchase')->__('Product'), 310, $this->y, 'UTF-8');
     //barre grise fin entete colonnes
     $this->y -= 8;
     $page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
     $this->y -= 15;
 }
Пример #15
0
 public function generateAction()
 {
     // Create new PDF document.
     $pdf = new Zend_Pdf();
     // 421 x 596 = A5 Landscape in pixels @ 72dpi
     $pdf->pages[] = new Zend_Pdf_Page(596, 421);
     $pdf->pages[] = new Zend_Pdf_Page(596, 421);
     $front = $pdf->pages[0];
     $back = $pdf->pages[1];
     // Create new font
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     // Apply font
     $front->setFont($font, 18);
     // Start at the top
     $y = 590;
     // With a left Margin of 10
     $x = 10;
     $front->drawText($this->recipe->name, $x, $y);
     $y = $y - 30;
     $front->setFont($font, 12);
     $front->drawText('Difficulty: ' . $this->recipe->difficulty, $x, $y);
     $y = $y - 15;
     $front->drawText('Preparation Time: ' . $this->recipe->preparation_time, $x, $y);
     $y = $y - 15;
     $front->drawText('Cooking Time: ' . $this->recipe->preparation_time, $x, $y);
     $y = $y - 15;
     $front->drawText('Serves: ' . $this->recipe->serves, $x, $y);
     $y = $y - 15;
     $front->drawText('Freezable: ' . $this->recipe->freezable, $x, $y);
     $ingredients = $this->recipe->findRecipeIngredient();
     $y = $y - 15;
     foreach ($ingredients as $ingredient) {
         $y = $y - 15;
         $text = '';
         if ($ingredient->quantity > 0) {
             $text .= $ingredient->quantity;
         }
         if ($ingredient->amount > 0) {
             $text .= $ingredient->amount . ' ';
         }
         if (!empty($ingredient->measurement)) {
             $text .= $ingredient->measurement_abbr . ' ';
         }
         $text .= $ingredient->name;
         $front->drawText($text, $x, $y);
     }
     $back->setFont($font, 18);
     $pdf->save('pdf/foo.pdf');
 }
Пример #16
0
 public function __construct($labels = array())
 {
     $cols = null;
     foreach ($labels as $label) {
         $col = new Core_Pdf_Table_Column();
         $col->setText($label);
         $cols[] = $col;
     }
     if ($cols) {
         $this->setColumns($cols);
     }
     //set default alignment
     $this->_align = Core_Pdf::CENTER;
     //set default borders
     $style = new Zend_Pdf_Style();
     $style->setLineWidth(2);
     $this->setBorder(Core_Pdf::BOTTOM, $style);
     $this->setCellPaddings(array(5, 5, 5, 5));
     //set default font
     $this->_font = Zend_Pdf_Font::fontWithName(ZEND_Pdf_Font::FONT_HELVETICA_BOLD);
     $this->_fontSize = 12;
 }
Пример #17
0
 /**
  * Creates and generates the PDF report for the items in the report.
  *
  * @param string $filePath The path to the zip that contains the generated
  * PDFs.
  */
 public function generateReport($filePath)
 {
     if (!extension_loaded('zip')) {
         throw new RuntimeException("zip extension is required to bundle " . "report PDF files.");
     }
     $options = unserialize($this->_reportFile->options);
     $this->_baseUrl = $options['baseUrl'];
     $this->_font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $fileSuffix = 1;
     $pdfPath = $this->_newPdf($filePath, $fileSuffix);
     while ($items = $this->_getItems()) {
         if ($this->_pdfPageCount >= $this->_pagesPerFile) {
             $fileSuffix++;
             $pdfPath = $this->_newPdf($filePath, $fileSuffix);
             _log("Created new PDF file '{$pdfPath}'");
             $this->_pdfPageCount = 0;
         }
         $this->_addItems($items, $pdfPath);
     }
     $this->_zipFiles($filePath);
     $this->_unlinkFiles();
     return $filePath;
 }
Пример #18
0
 private function gerarCertificado($idEncontro, $array = array())
 {
     // include auto-loader class
     require_once 'Zend/Loader/Autoloader.php';
     // register auto-loader
     $loader = Zend_Loader_Autoloader::getInstance();
     $pdf = new Zend_Pdf();
     $page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
     $font = Zend_Pdf_Font::fontWithPath(APPLICATION_PATH . "/../public/font/UbuntuMono-R.ttf");
     $page1->setFont($font, Sige_Pdf_Certificado::TAM_FONTE);
     // configura o plano de fundo
     $this->background($page1, $idEncontro);
     for ($index = 0; $index < count($array); $index++) {
         $page1->drawText($array[$index], Sige_Pdf_Certificado::POS_X_INICIAL, Sige_Pdf_Certificado::POS_Y_INICIAL - $index * Sige_Pdf_Certificado::DES_Y, 'UTF-8');
     }
     // configura a(s) assinatura(s)
     $this->assinaturas($page1, $idEncontro);
     $pdf->pages[] = $page1;
     // salve apenas em modo debug!
     // $pdf->save(APPLICATION_PATH . '/../tmp/certificado-participante.pdf');
     // Get PDF document as a string
     return $pdf->render();
 }
 public function getPdf($orders = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     //on cree le pdf que si il n'est pas déja défini( ca permet de mettre plrs documents dans le mm pdf (genre une facture, un BL ....)
     $this->pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     //cree la nouvelle page
     $titre = mage::helper('purchase')->__('Order Comments');
     $settings = array();
     $settings['title'] = $titre;
     $settings['store_id'] = 0;
     $page = $this->NewPage($settings);
     $this->y -= $this->_ITEM_HEIGHT * 2;
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
     //Rajoute les commandes avec commentaires
     foreach ($orders as $order) {
         $comments = mage::helper('Organizer')->getEntityCommentsSummary('order', $order->getorder_id(), false);
         if ($comments != '') {
             $realOrder = mage::getModel('sales/order')->load($order->getorder_id());
             $page->drawText(mage::helper('purchase')->__('Order # ') . $realOrder->getIncrementId(), 15, $this->y, 'UTF-8');
             $comments = $this->WrapTextToWidth($page, $comments, 450);
             $offset = $this->DrawMultilineText($page, $comments, 150, $this->y, 10, 0.2, 11);
             $this->y -= 8 + $offset;
             $page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
             $this->y -= 15;
         }
     }
     //dessine le pied de page
     $this->drawFooter($page);
     //rajoute la pagination
     $this->AddPagination($this->pdf);
     $this->_afterGetPdf();
     return $this->pdf;
 }
Пример #20
0
 /**
  * Object constructor
  *
  * $fontDictionary is a Zend_Pdf_Element_Reference or Zend_Pdf_Element_Object object
  *
  * @param mixed $fontDictionary
  * @throws Zend_Pdf_Exception
  */
 public function __construct($fontDictionary)
 {
     // Extract object factory and resource object from font dirctionary object
     $this->_objectFactory = $fontDictionary->getFactory();
     $this->_resource = $fontDictionary;
     if ($fontDictionary->Encoding !== null) {
         $this->_encoding = $fontDictionary->Encoding->value;
     }
     switch ($fontDictionary->Subtype->value) {
         case 'Type0':
             // Composite type 0 font
             if (count($fontDictionary->DescendantFonts->items) != 1) {
                 // Multiple descendant fonts are not supported
                 //$1 'Zend/Pdf/Exception.php';
                 throw new Zend_Pdf_Exception(self::TYPE_NOT_SUPPORTED);
             }
             $fontDictionaryIterator = $fontDictionary->DescendantFonts->items->getIterator();
             $fontDictionaryIterator->rewind();
             $descendantFont = $fontDictionaryIterator->current();
             $fontDescriptor = $descendantFont->FontDescriptor;
             break;
         case 'Type1':
             if ($fontDictionary->FontDescriptor === null) {
                 // That's one of the standard fonts
                 $standardFont = Zend_Pdf_Font::fontWithName($fontDictionary->BaseFont->value);
                 $this->_fontNames = $standardFont->getFontNames();
                 $this->_isBold = $standardFont->isBold();
                 $this->_isItalic = $standardFont->isItalic();
                 $this->_isMonospace = $standardFont->isMonospace();
                 $this->_underlinePosition = $standardFont->getUnderlinePosition();
                 $this->_underlineThickness = $standardFont->getUnderlineThickness();
                 $this->_strikePosition = $standardFont->getStrikePosition();
                 $this->_strikeThickness = $standardFont->getStrikeThickness();
                 $this->_unitsPerEm = $standardFont->getUnitsPerEm();
                 $this->_ascent = $standardFont->getAscent();
                 $this->_descent = $standardFont->getDescent();
                 $this->_lineGap = $standardFont->getLineGap();
                 return;
             }
             $fontDescriptor = $fontDictionary->FontDescriptor;
             break;
         case 'TrueType':
             $fontDescriptor = $fontDictionary->FontDescriptor;
             break;
         default:
             //$1 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception(self::TYPE_NOT_SUPPORTED);
     }
     $this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] = iconv('UTF-8', 'UTF-16BE', $fontDictionary->BaseFont->value);
     $this->_isBold = false;
     // this property is actually not used anywhere
     $this->_isItalic = ($fontDescriptor->Flags->value & 1 << 6) != 0;
     // Bit-7 is set
     $this->_isMonospace = ($fontDescriptor->Flags->value & 1 << 0) != 0;
     // Bit-1 is set
     $this->_underlinePosition = null;
     // Can't be extracted
     $this->_underlineThickness = null;
     // Can't be extracted
     $this->_strikePosition = null;
     // Can't be extracted
     $this->_strikeThickness = null;
     // Can't be extracted
     $this->_unitsPerEm = null;
     // Can't be extracted
     $this->_ascent = $fontDescriptor->Ascent->value;
     $this->_descent = $fontDescriptor->Descent->value;
     $this->_lineGap = null;
     // Can't be extracted
 }
Пример #21
0
 /**
  * Returns a {@link Zend_Pdf_Resource_Font} object by file path.
  *
  * The result of this method is cached, preventing unnecessary duplication
  * of font objects. Repetitive calls for the font with the same path will
  * return the same object.
  *
  * The $embeddingOptions parameter allows you to set certain flags related
  * to font embedding. You may combine options by OR-ing them together. See
  * the EMBED_ constants defined in {@link Zend_Pdf_Font} for the list of
  * available options and their descriptions. Note that this value is only
  * used when creating a font for the first time. If a font with the same
  * name already exists, you will get that object and the options you specify
  * here will be ignored. This is because fonts are only embedded within the
  * PDF file once.
  *
  * If the file path supplied does not match the path of a previously
  * instantiated object or the font type cannot be determined, an exception
  * will be thrown.
  *
  * @param string $filePath Full path to the font file.
  * @param integer $embeddingOptions (optional) Options for font embedding.
  * @return Zend_Pdf_Resource_Font
  * @throws Zend_Pdf_Exception
  */
 public static function fontWithPath($filePath, $embeddingOptions = 0)
 {
     /* First check the cache. Don't duplicate font objects.
      */
     $filePathKey = md5($filePath);
     if (isset(Zend_Pdf_Font::$_fontFilePaths[$filePathKey])) {
         return Zend_Pdf_Font::$_fontFilePaths[$filePathKey];
     }
     /* Create a file parser data source object for this file. File path and
      * access permission checks are handled here.
      */
     $dataSource = new Zend_Pdf_FileParserDataSource_File($filePath);
     /* Attempt to determine the type of font. We can't always trust file
      * extensions, but try that first since it's fastest.
      */
     $fileExtension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
     /* If it turns out that the file is named improperly and we guess the
      * wrong type, we'll get null instead of a font object.
      */
     switch ($fileExtension) {
         case 'ttf':
             $font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
             break;
         default:
             /* Unrecognized extension. Try to determine the type by actually
              * parsing it below.
              */
             $font = null;
             break;
     }
     if ($font === null) {
         /* There was no match for the file extension or the extension was
          * wrong. Attempt to detect the type of font by actually parsing it.
          * We'll do the checks in order of most likely format to try to
          * reduce the detection time.
          */
         // OpenType
         // TrueType
         if ($font === null && $fileExtension != 'ttf') {
             $font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
         }
         // Type 1 PostScript
         // Mac OS X dfont
         // others?
     }
     /* Done with the data source object.
      */
     $dataSource = null;
     if ($font !== null) {
         /* Parsing was successful. Add this font instance to the cache arrays
          * and return it for use.
          */
         $fontName = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, '', '');
         Zend_Pdf_Font::$_fontNames[$fontName] = $font;
         $filePathKey = md5($filePath);
         Zend_Pdf_Font::$_fontFilePaths[$filePathKey] = $font;
         return $font;
     } else {
         /* The type of font could not be determined. Give up.
          */
         throw new Zend_Pdf_Exception("Cannot determine font type: {$filePath}", Zend_Pdf_Exception::CANT_DETERMINE_FONT_TYPE);
     }
 }
Пример #22
0
 function pdfdisplayAction()
 {
     $app = $this->view->baseUrl();
     $word = explode('/', $app);
     $projname = $word[1];
     $pdf = new Zend_Pdf();
     $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
     $pdf->pages[] = $page;
     // Image
     $image_name = "/var/www/" . $projname . "/public/images/logo.jpg";
     $image = Zend_Pdf_Image::imageWithPath($image_name);
     //$page->drawImage($image, 25, 770, 570, 820);
     $page->drawImage($image, 30, 770, 130, 820);
     $page->setLineWidth(1)->drawLine(25, 25, 570, 25);
     //bottom horizontal
     // 		$page->setLineWidth(1)->drawLine(25, 640, 25, 500);
     $page->setLineWidth(1)->drawLine(25, 25, 25, 820);
     //left vertical
     $page->setLineWidth(1)->drawLine(570, 25, 570, 820);
     //right vertical
     $page->setLineWidth(1)->drawLine(570, 820, 25, 820);
     //top horizonta
     // define font resource
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     // Image
     $image_name = "/var/www/" . $projname . "/public/images/logo.jpg";
     $image = Zend_Pdf_Image::imageWithPath($image_name);
     $x1 = 72;
     $x2 = 410;
     $y1 = 690;
     $Declaration = new Declaration_Model_Dec();
     $code = $this->_request->getParam('groupcode');
     $this->view->result = $this->view->loan->groupDeatils($code);
     $this->view->groupmembers = $this->view->loan->getgroupmembers($code);
     $dateconvert = new App_Model_dateConvertor();
     foreach ($this->view->result as $result) {
         //    // write text to page
         $page->setFont($font, 12)->drawText('Group bye law', 240, 720);
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate local development by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate local development by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate local development by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate   ' . $result['dayname'] . 'The vision of Ourbank is to stimulate ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to    ' . $result['place'] . '  stimulate local development by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate  ' . $result['saving_perweek'] . '  pment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimu  ' . $result['rateinterest'] . '  velopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stim  ' . $result['penalty_latecoming'] . '  evelopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stim   ' . $result['penalty_notcoming'] . '  velopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to st   ' . $result['group_created_date'] . '   elopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimu    ' . $result['name'] . '    elopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setLineWidth(1)->drawLine(50, $y1, 550, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('Member name', 72, $y1);
         $page->setFont($font, 9)->drawText('UID', 160, $y1);
         $page->setFont($font, 9)->drawText('Father name', 200, $y1);
         $page->setFont($font, 9)->drawText('Nominee', 280, $y1);
         $page->setFont($font, 9)->drawText('Nominee relationship', 350, $y1);
         $page->setFont($font, 9)->drawText('Signature', 460, $y1);
         $y1 = $y1 - 10;
         $page->setLineWidth(1)->drawLine(50, $y1, 550, $y1);
         foreach ($this->view->groupmembers as $member) {
             $y1 = $y1 - 15;
             $page->setFont($font, 9)->drawText('' . $member['membername'] . '', 72, $y1);
             $page->setFont($font, 9)->drawText('' . $member['uid'] . '', 140, $y1);
             $page->setFont($font, 9)->drawText('' . $member['family_id'] . '', 200, $y1);
             $y1 = $y1 - 10;
             $page->setLineWidth(1)->drawLine(50, $y1, 550, $y1);
         }
     }
     $pdf->pages[] = $page;
     $pdfData = $pdf->render();
     $pdfData = $pdf->render();
     $pdf->save('/var/www/' . $projname . '/reports/grouplaw.pdf');
     $path = '/var/www/' . $projname . '/reports/grouplaw.pdf';
     chmod($path, 0777);
     //                 $this->_redirect('/declaration/index');
 }
 public function setFontBold($type = Zend_Pdf_Font::FONT_TIMES_BOLD)
 {
     if ($this->isZendPdfFont($type)) {
         $this->_fontBold = Zend_Pdf_Font::fontWithName($type);
     } else {
         $this->_fontBold = Zend_Pdf_Font::fontWithPath(realpath(dirname(dirname(__FILE__))) . "/Fonts/" . $type);
     }
     return $this;
 }
Пример #24
0
 public function getPdf($shipments = array())
 {
     $pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     foreach ($shipments as $shipment) {
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
         $pdf->pages[] = $page;
         $order = $shipment->getOrder();
         /* Add image */
         $this->insertLogo($page);
         /* Add address */
         $this->insertAddress($page);
         /* Add head */
         $this->insertOrder($page, $order);
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 7);
         $page->drawText(Mage::helper('sales')->__('Packingslip # ') . $shipment->getIncrementId(), 35, 780);
         /* Add table */
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
         $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
         $page->setLineWidth(0.5);
         /* Add table head */
         $page->drawRectangle(25, $this->y, 570, $this->y - 15);
         $this->y -= 10;
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
         $page->drawText(Mage::helper('sales')->__('QTY'), 35, $this->y);
         $page->drawText(Mage::helper('sales')->__('Products'), 60, $this->y);
         $page->drawText(Mage::helper('sales')->__('SKU'), 470, $this->y);
         $this->y -= 15;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         /* Add body */
         foreach ($shipment->getAllItems() as $item) {
             $shift = 10;
             if ($this->y < 15) {
                 /* Add new table head */
                 $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
                 $pdf->pages[] = $page;
                 $this->y = 800;
                 $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 7);
                 $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
                 $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
                 $page->setLineWidth(0.5);
                 $page->drawRectangle(25, $this->y, 570, $this->y - 15);
                 $this->y -= 10;
                 $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
                 $page->drawText(Mage::helper('sales')->__('QTY'), 35, $this->y);
                 $page->drawText(Mage::helper('sales')->__('Products'), 60, $this->y);
                 $page->drawText(Mage::helper('sales')->__('SKU'), 470, $this->y);
                 $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                 $this->y -= 20;
             }
             /* Add products */
             $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 7);
             $page->drawText($item->getQty() * 1, 35, $this->y);
             $page->drawText($item->getName(), 60, $this->y);
             $page->drawText($item->getName(), 60, $this->y);
             foreach (explode('</li>', $item->getDescription()) as $description) {
                 $page->drawText(strip_tags($description), 65, $this->y - $shift);
                 $shift += 10;
             }
             $page->drawText($item->getSku(), 470, $this->y);
             $this->y -= $shift;
         }
     }
     return $pdf;
 }
Пример #25
0
 public function buildPageStructure($titles, $firstPage = false)
 {
     if (strtoupper($this->_deploy['size'] = 'LETTER') && strtoupper($this->_deploy['orientation']) == 'LANDSCAPE') {
         $this->_page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE);
     } elseif (strtoupper($this->_deploy['size'] = 'LETTER') && strtoupper($this->_deploy['orientation']) != 'LANDSCAPE') {
         $this->_page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
     } elseif (strtoupper($this->_deploy['size'] != 'A4') && strtoupper($this->_deploy['orientation']) == 'LANDSCAPE') {
         $this->_page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
     } else {
         $this->_page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     }
     if ($firstPage === true) {
         return;
     }
     $this->_page->setStyle($this->_styles['style']);
     $this->_pdf->pages[] = $this->_page;
     $this->_currentPage++;
     $this->_font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $this->_page->setFont($this->_font, $this->getDeployOption('headerFontSize', 14));
     if (file_exists($this->_deploy['logo'])) {
         $image = Zend_Pdf_Image::imageWithPath($this->_deploy['logo']);
         list($this->_width, $this->_height, $type, $attr) = getimagesize($this->_deploy['logo']);
         $this->_page->drawImage($image, 40, $this->_page->getHeight() - $this->_height - 40, 40 + $this->_width, $this->_page->getHeight() - 40);
     }
     $this->_page->drawText($this->__($this->_deploy['title']), $this->_width + 70, $this->_page->getHeight() - 70, $this->getCharEncoding());
     $this->_page->setFont($this->_font, $this->_cellFontSize);
     $this->_page->drawText($this->__($this->_deploy['subtitle']), $this->_width + 70, $this->_page->getHeight() - 80, $this->getCharEncoding());
     $this->_height = $this->_page->getHeight() - 120;
     $this->_page->drawText($this->__($this->_deploy['footer']), 40, 40, $this->getCharEncoding());
     if ($this->_deploy['noPagination'] != 1) {
         $this->_page->drawText($this->__($this->_deploy['page']) . ' ' . $this->_currentPage . '/' . $this->_totalPages, $this->_page->getWidth() - strlen($this->__($this->_deploy['page'])) * $this->_cellFontSize - 50, 40, $this->getCharEncoding());
     }
     reset($titles);
     $i = 0;
     $largura1 = 40;
     $this->_page->setFont($this->_font, $this->_cellFontSize + 1);
     foreach ($titles as $title) {
         if ($title['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
             if ((int) $this->_la == 0) {
                 $largura1 = 40;
             } else {
                 @($largura1 = $this->_cell[$i - 1] + $largura1);
             }
             $this->_page->setStyle($this->_styles['topo']);
             $this->_page->drawRectangle($largura1, $this->_height - 8, $largura1 + $this->_cell[$i] + 1, $this->_height + 12);
             $this->_page->setStyle($this->_styles['style']);
             $this->_page->drawText($title['value'], $largura1 + 2, $this->_height, $this->getCharEncoding());
             $this->_la = $largura1;
             $i++;
         }
         $this->_page->setFont($this->_font, $this->_cellFontSize);
     }
 }
Пример #26
0
 /**
  * Insert an applicant's details into a PDF.
  *
  * @param Model_Referencing_Reference $reference Reference object
  * @return void
  */
 public function applicantPopulate(Model_Referencing_Reference $reference)
 {
     // Overflow and trim address as necessary
     $address = $reference->propertyLease->address;
     $addressLine1 = trim("{$address->flatNumber} {$address->houseName} {$address->houseNumber} {$address->addressLine1} {$address->town} {$address->county}");
     $postCode = $address->postCode;
     $fontSize = 10;
     // points
     $this->_pdfMerge->pdfPageStyle->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), $fontSize);
     $textPlacements = array();
     // Page 0 has special placement requirements
     // Reference number
     $textPlacements[] = new Model_Core_Pdf_Element(0, $reference->internalId, 120, 262);
     // Surname
     $textPlacements[] = new Model_Core_Pdf_Element(0, strtoupper($reference->referenceSubject->name->lastName), 367, 262);
     // Address line 1
     $textPlacements[] = new Model_Core_Pdf_Element(0, strtoupper($addressLine1), 135, 392);
     // Postcode
     $textPlacements[] = new Model_Core_Pdf_Element(0, strtoupper($postCode), 135, 413);
     // Total rent for the property
     $textPlacements[] = new Model_Core_Pdf_Element(0, $reference->propertyLease->rentPerMonth->getValue(), 330, 413);
     // Share of rent for the property
     $textPlacements[] = new Model_Core_Pdf_Element(0, $reference->referenceSubject->shareOfRent->getValue(), 170, 462);
     // Duration of tenancy
     $textPlacements[] = new Model_Core_Pdf_Element(0, sprintf('%02d', $reference->propertyLease->tenancyTerm), 170, 609);
     // Expected tenancy start date (day)
     $textPlacements[] = new Model_Core_Pdf_Element(0, $reference->propertyLease->tenancyStartDate->toString('dd'), 286, 609);
     // Expected tenancy start date (month)
     $textPlacements[] = new Model_Core_Pdf_Element(0, $reference->propertyLease->tenancyStartDate->toString('MM'), 304, 609);
     // Expected tenancy start date (year)
     $textPlacements[] = new Model_Core_Pdf_Element(0, $reference->propertyLease->tenancyStartDate->toString('YY'), 321, 609);
     $this->_pdfMerge->merge($textPlacements);
 }
Пример #27
0
 /**
  * Create font instances
  */
 public function __construct()
 {
     $this->_fontNormal = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $this->_fontBold = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
 }
Пример #28
0
 /**
  * Function apply prototype of page (list of pdf tables and text lines).
  *
  * @param array  $prototype Specifies form of elements in the PDF page.
  *              E.g. array(
  *                      'font' => 'Helvetica',
  *                      'fontSize' => 10,
  *                      0 => array(
  *                         'type' =>'table',
  *                         'startX'=> 35,
  *                         'startY'=> 60,
  *                         'rows' => array(...)
  *                      ),
  *                      1 => array(
  *                         'type' =>'freetext',
  *                         'startX'=> 35,
  *                         'startY'=> 100,
  *                         'lines' => array('line1', 'line2')
  *                      ),
  *                      2 => array(
  *                         'type' =>'infoBox',
  *                         'startX'=> 35,
  *                         'startY'=> 100,
  *                         'lines' => array('line1', 'line2'),
  *                         'width' => 100,
  *                         'height' => 100,
  *                         'header' => 'Header'
  *                      ),
  *                  )
  * @param string $encoding Encoding of the text string $str, UTF-8 by default.
  *
  * @return array Array of FFR_Pdf_PdfGenerator.
  */
 public function parseTemplate($prototype, $encoding = 'UTF-8')
 {
     $pages = array($this);
     $currentPage = $this;
     $fontName = isset($prototype['font']) ? $prototype['font'] : Zend_Pdf_Font::FONT_HELVETICA;
     $fontSize = isset($prototype['fontSize']) ? $prototype['fontSize'] : self::DEFAULT_FONT_SIZE;
     $font = Zend_Pdf_Font::fontWithName($fontName);
     foreach ($prototype as $element) {
         if (!isset($element['type'])) {
             continue;
         }
         $currentPage->setFont($font, $fontSize);
         switch ($element['type']) {
             case 'table':
                 $pages += $this->addTable($element, $currentPage, $encoding);
                 $currentPage = end($pages);
                 break;
             case 'freetext':
                 $this->addFreetext($element, $currentPage, $encoding);
                 break;
         }
     }
     return $pages;
 }
Пример #29
0
 /**
  * Draw lines
  *
  * Draw items array format:
  * lines        array;array of line blocks (required)
  * shift        int; full line height (optional)
  * height       int;line spacing (default 10)
  *
  * line block has line columns array
  *
  * column array format
  * text         string|array; draw text (required)
  * feed         int; x position (required)
  * font         string; font style, optional: bold, italic, regular
  * font_file    string; path to font file (optional for use your custom font)
  * font_size    int; font size (default 7)
  * align        string; text align (also see feed parametr), optional left, right
  * height       int;line spacing (default 10)
  *
  * @param  \Zend_Pdf_Page $page
  * @param  array $draw
  * @param  array $pageSettings
  * @throws \Magento\Framework\Model\Exception
  * @return \Zend_Pdf_Page
  */
 public function drawLineBlocks(\Zend_Pdf_Page $page, array $draw, array $pageSettings = array())
 {
     foreach ($draw as $itemsProp) {
         if (!isset($itemsProp['lines']) || !is_array($itemsProp['lines'])) {
             throw new \Magento\Framework\Model\Exception(__('We don\'t recognize the draw line data. Please define the "lines" array.'));
         }
         $lines = $itemsProp['lines'];
         $height = isset($itemsProp['height']) ? $itemsProp['height'] : 10;
         if (empty($itemsProp['shift'])) {
             $shift = 0;
             foreach ($lines as $line) {
                 $maxHeight = 0;
                 foreach ($line as $column) {
                     $lineSpacing = !empty($column['height']) ? $column['height'] : $height;
                     if (!is_array($column['text'])) {
                         $column['text'] = array($column['text']);
                     }
                     $top = 0;
                     foreach ($column['text'] as $part) {
                         $top += $lineSpacing;
                     }
                     $maxHeight = $top > $maxHeight ? $top : $maxHeight;
                 }
                 $shift += $maxHeight;
             }
             $itemsProp['shift'] = $shift;
         }
         if ($this->y - $itemsProp['shift'] < 15) {
             $page = $this->newPage($pageSettings);
         }
         foreach ($lines as $line) {
             $maxHeight = 0;
             foreach ($line as $column) {
                 $fontSize = empty($column['font_size']) ? 10 : $column['font_size'];
                 if (!empty($column['font_file'])) {
                     $font = \Zend_Pdf_Font::fontWithPath($column['font_file']);
                     $page->setFont($font, $fontSize);
                 } else {
                     $fontStyle = empty($column['font']) ? 'regular' : $column['font'];
                     switch ($fontStyle) {
                         case 'bold':
                             $font = $this->_setFontBold($page, $fontSize);
                             break;
                         case 'italic':
                             $font = $this->_setFontItalic($page, $fontSize);
                             break;
                         default:
                             $font = $this->_setFontRegular($page, $fontSize);
                             break;
                     }
                 }
                 if (!is_array($column['text'])) {
                     $column['text'] = array($column['text']);
                 }
                 $lineSpacing = !empty($column['height']) ? $column['height'] : $height;
                 $top = 0;
                 foreach ($column['text'] as $part) {
                     if ($this->y - $lineSpacing < 15) {
                         $page = $this->newPage($pageSettings);
                     }
                     $feed = $column['feed'];
                     $textAlign = empty($column['align']) ? 'left' : $column['align'];
                     $width = empty($column['width']) ? 0 : $column['width'];
                     switch ($textAlign) {
                         case 'right':
                             if ($width) {
                                 $feed = $this->getAlignRight($part, $feed, $width, $font, $fontSize);
                             } else {
                                 $feed = $feed - $this->widthForStringUsingFontSize($part, $font, $fontSize);
                             }
                             break;
                         case 'center':
                             if ($width) {
                                 $feed = $this->getAlignCenter($part, $feed, $width, $font, $fontSize);
                             }
                             break;
                         default:
                             break;
                     }
                     $page->drawText($part, $feed, $this->y - $top, 'UTF-8');
                     $top += $lineSpacing;
                 }
                 $maxHeight = $top > $maxHeight ? $top : $maxHeight;
             }
             $this->y -= $maxHeight;
         }
     }
     return $page;
 }
Пример #30
0
 function pdfgenerationAction()
 {
     //$fetchMeetings=new Meetingreport_Model_Meetingreport();
     $pdf = new Zend_Pdf();
     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     // 		 $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
     $pdf->pages[] = $page;
     // Image
     $app = $this->view->baseUrl();
     $word = explode('/', $app);
     $projname = '';
     for ($i = 0; $i < count($word); $i++) {
         if ($i > 0 && $i < count($word) - 1) {
             $projname .= '/' . $word[$i];
         }
     }
     $image_name = "/var/www" . $app . "/images/logo.jpg";
     $image = Zend_Pdf_Image::imageWithPath($image_name);
     //$page->drawImage($image, 25, 770, 570, 820);
     $page->drawImage($image, 30, 770, 130, 820);
     $page->setLineWidth(1)->drawLine(25, 25, 570, 25);
     //bottom horizontal
     $page->setLineWidth(1)->drawLine(25, 25, 25, 820);
     //left vertical
     $page->setLineWidth(1)->drawLine(570, 25, 570, 820);
     //right vertical
     $page->setLineWidth(1)->drawLine(570, 820, 25, 820);
     //top horizontal
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 8);
     $text = array("Bank", "Branch", "Thumb Impression Declaration", "I hereby declare that Smt/sri ______________________ has given the thumb impression in the presence of me and his mother tongue", " ___________________________", "Date", "Yours sincerely");
     $x0 = 60;
     $x10 = 450;
     $x11 = 285;
     $page->drawText($text[0], $x0, 725);
     $page->drawText($text[1], $x0, 700);
     $page->drawText($text[2], $x0, 675);
     $page->drawText($text[3], $x0, 650);
     $page->drawText($text[4], $x0, 625);
     $page->drawText($text[5], $x0, 575);
     $page->drawText($text[6], $x10, 575);
     $page->setLineWidth(1)->drawLine(50, 750, 550, 750);
     $page->setLineWidth(1)->drawLine(50, 750, 50, 465);
     $page->setLineWidth(1)->drawLine(50, 750, 50, 465);
     $page->setLineWidth(1)->drawLine(50, 465, 550, 465);
     $page->setLineWidth(1)->drawLine(550, 465, 550, 750);
     $page->setLineWidth(1)->drawLine(50, 690, 550, 690);
     $page->setLineWidth(1)->drawLine(50, 670, 550, 670);
     $y1 = 700;
     $totalAmount = "0";
     $totaldebit = "0";
     $pdfData = $pdf->render();
     $pdf->save('/var/www' . $projname . '/reports/thumbdeclaration' . date('Y-m-d') . '.pdf');
     $path = '/var/www' . $projname . '/reports/thumbdeclaration' . date('Y-m-d') . '.pdf';
     chmod($path, 0777);
 }