/** * 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(); }
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'); }
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"); } }
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 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); }
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; }
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); }
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); }
public function getPdf() { $pdf = new Zend_Pdf(); $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4); $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES); $page->setFont($font, 12); $width = $page->getWidth(); $i = 0; $this->insertLogo($page); $this->insertAddress($page); /*$page->setFillColor(new Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92)); $page->drawRectangle(25, $this->y + 15, 190, $this->y - 35); $page->drawRectangle(190, $this->y + 15, 350, $this->y - 35); $page->drawRectangle(350, $this->y + 15, 570, $this->y - 35);*/ $page->setFont($font, 16); $this->y -= 50; $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.5)); $page->drawRectangle(25, $this->y + 15, 573, $this->y - 57); $page->setFillColor(new Zend_Pdf_Color_Html('#ffffff')); $headerText = "Report: Net Sales & Tax"; $page->drawText($headerText, 30, $this->y, 'UTF-8'); $this->y -= 22; $page->drawText("From: " . $this->from, 30, $this->y, 'UTF-8'); $this->y -= 22; $page->drawText("To: " . $this->to, 30, $this->y, 'UTF-8'); $page->setFont($font, 14); $this->y -= 50; $page->setFillColor(new Zend_Pdf_Color_GrayScale(0)); $totalText = Mage::helper('sales')->__('Total Net Sale'); $page->drawText($totalText, 25, $this->y, 'UTF-8'); $total = Mage::helper('core')->currency($this->getTotalSale(), true, false); $page->drawText($total, 505, $this->y, 'UTF-8'); $this->y -= 50; $page->setFillColor(new Zend_Pdf_Color_GrayScale(0)); $totalText = Mage::helper('sales')->__('Net Sales Texas Only'); $page->drawText($totalText, 25, $this->y, 'UTF-8'); $total = Mage::helper('core')->currency($this->getTotalTexasSale(), true, false); $page->drawText($total, 505, $this->y, 'UTF-8'); $this->y -= 50; $page->setFillColor(new Zend_Pdf_Color_GrayScale(0)); $totalText = Mage::helper('sales')->__('Net Shipping Costs for Texas only'); $page->drawText($totalText, 25, $this->y, 'UTF-8'); $total = Mage::helper('core')->currency($this->getTotalTexasShipping(), true, false); $page->drawText($total, 505, $this->y, 'UTF-8'); $this->y -= 50; $page->setFillColor(new Zend_Pdf_Color_GrayScale(0)); $totalText = Mage::helper('sales')->__('Texas Net Sales Tax'); $page->drawText($totalText, 25, $this->y, 'UTF-8'); $total = Mage::helper('core')->currency($this->getTotalTexasTax(), true, false); $page->drawText($total, 505, $this->y, 'UTF-8'); $pdf->pages[] = $page; return $pdf->render(); }
/** * 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(); }
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; }
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'); }
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; }
/** * 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; }
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; }
/** * 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); }
/** * 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); }
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); }
/** * 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; }
function pdftransactionAction() { $fromdate = $this->_request->getParam('fdate'); $dateconvertor = new App_Model_dateConvertor(); $Date = $dateconvertor->mysqlformat($fromdate); $this->view->fdate = $Date; $asofDate = $dateconvertor->normalformat($fromdate); $this->view->asofdate = $asofDate; $incomeexpenditure = new Incomeexpenditure_Model_Incomeexpenditure(); $this->view->income = $income = $incomeexpenditure->incomedetails($Date); $this->view->expenditure = $expenditure = $incomeexpenditure->expendituredetails($Date); $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]; } } $pdf = new Zend_Pdf(); $page = $pdf->newPage(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, 20, 780, 120, 830); $page->setLineWidth(1)->drawLine(20, 20, 580, 20); //bottom horizontal $page->setLineWidth(1)->drawLine(20, 20, 20, 830); //left vertical $page->setLineWidth(1)->drawLine(580, 25, 580, 830); //right vertical $page->setLineWidth(1)->drawLine(20, 830, 580, 830); //top horizontal $x1 = 45; $x2 = 250; $x3 = 330; $x4 = 500; $my = 735; $y1 = 710; $y2 = 710; $totalincome = 0; $totalexpe = 0; //set the font $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 8); $text = array($this->view->translate('Income and Expenditure'), $this->view->translate('Income'), $this->view->translate('Amount'), $this->view->translate('Expenditure'), $this->view->translate('Amount'), $this->view->translate('Grand total')); $criteria = $this->view->translate('As of') . " " . $asofDate; $currency = "* " . $this->view->translate('Amount in Rs'); // // // file:///var/www/IDF/application/modules/incomeexpenditure/controllers/IndexController.php /*$page->drawText("Date : ".date('d/m/Y'),500, 800); //date('Y-m-d') $page->drawText("Date : ".date('d/m/Y'),500, 800);*/ $page->drawText($text[0], 185, 780); $page->drawText($text[0], 185, 780); $page->drawText($criteria, 500, 780); //Search criteria $page->drawText($criteria, 500, 780); $page->drawText($currency, 500, 770); //Currency $page->drawText($currency, 500, 770); $page->drawText($text[1], $x1, $my); $page->drawText($text[2], $x2, $my); $page->drawText($text[3], $x3, $my); $page->drawText($text[4], $x4, $my); $page->drawLine(30, 750, 570, 750); $page->drawLine(30, 730, 570, 730); foreach ($income as $income) { $page->drawText($income['header'], $x1, $y1); $page->drawText($income['credit'], $x2, $y1); $totalincome += $income['credit']; $y1 = $y1 - 15; } foreach ($expenditure as $expe) { $page->drawText($expe['header'], $x3, $y2); $page->drawText($expe['credit'], $x4, $y2); $totalexpe += $expe['credit']; $y2 = $y2 - 15; } $page->drawLine(30, $y1, 570, $y1); $page->drawLine(30, $y1 - 20, 570, $y1 - 20); $page->drawText($text[5], $x1, $y1 - 15); $page->drawText(sprintf("%4.2f", $totalincome), $x2, $y1 - 15); $page->drawText($text[5], $x3, $y1 - 15); $page->drawText(sprintf("%4.2f", $totalexpe), $x4, $y1 - 15); // Virtual table $page->setLineWidth(1)->drawLine(30, $y1 - 20, 30, 750); //Table left vertical $page->setLineWidth(1)->drawLine(300, $y1 - 20, 300, 750); //Table center vertical $page->setLineWidth(1)->drawLine(570, $y1 - 20, 570, 750); //table rigth vertical $pdfData = $pdf->render(); $account_number = $Date; // $pdf->save('/var/www/ourbank/reports/incomeexpenditure.pdf'); //$path = '/var/www/ourbank/reports/incomeexpenditure.pdf'; $pdf->save('/var/www/' . $projname . '/reports/' . $account_number . 'incomeexpenditure.pdf'); $path = '/var/www/' . $projname . '/reports/' . $account_number . 'incomeexpenditure.pdf'; chmod($path, 0777); }
public function pdfAction() { //$oid = $this->getRequest()->getParams('orderid'); //echo $oid; $last_order_id = Mage::getSingleton('checkout/session')->getLastOrderId(); $pre_order_id = $last_order_id - 1; $pre_order = Mage::getModel('sales/order')->load($pre_order_id); $pre_deposit_val = $pre_order->getDepositId(); $current_deposit_value = $pre_deposit_val + 1; $connection = Mage::getSingleton('core/resource')->getConnection('core_write'); $connection->beginTransaction(); $__fields = array(); $__fields['deposit_id'] = $current_deposit_value; $__where = $connection->quoteInto('entity_id =?', $last_order_id); $connection->update('zaybx_sales_flat_order', $__fields, $__where); $connection->commit(); $curr_order = Mage::getModel('sales/order')->load($last_order_id); $display_deposit = $curr_order->getDepositId(); $strlen = strlen($display_deposit); if ($strlen == 1) { $original_deposit_id = "00000" . $display_deposit; } else { if ($strlen == 2) { $original_deposit_id = "0000" . $display_deposit; } else { if ($strlen == 3) { $original_deposit_id = "000" . $display_deposit; } else { if ($strlen == 4) { $original_deposit_id = "00" . $display_deposit; } else { if ($strlen == 5) { $original_deposit_id = "0" . $display_deposit; } else { $original_deposit_id = $display_deposit; } } } } } $order = Mage::getModel('sales/order'); $order_id = $this->getRequest()->getParams('orderid'); $order->loadByIncrementId($order_id); $payment_method_code = $order->getPayment()->getMethodInstance()->getCode(); $customername = $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(); //$currentdate = Mage::getModel('core/date')->date('Y-m-d H:i:s'); $currentdate = Mage::getModel('core/date')->date('d-m-Y'); $depositno = mt_rand(01, 100000); //$depositno = '000001'; $grandtotal = floatval(round($order->getGrandTotal(), 2)); $total = floatval(round($order->getGrandTotal(), 2)); $companyname = 'CLEARTHINK SOFTWARE PRIVATE LIMITED.'; $clientcode = 'CLRTNKSFTW'; $localchq = $order->getPayment()->getCheqloc(); if ($localchq == 1) { $local = ''; $out = ''; } else { $local = ''; $out = ''; } // $localchqdd = $order->getPayment()->getCheqlocdd(); // if($localchqdd == 1){ // $local = 'Yes'; // $out = 'No'; // }else{ // $local = 'No'; // $out = 'Yes'; // } $order_ic_id = $order->getIncrementId(); $checkno = $order->getPayment()->getCheckNo(); $chqdate = $order->getPayment()->getCheckDate(); $draweename = $order->getPayment()->getDraweename(); $draweebank = $order->getPayment()->getDraweebank(); $panno = $order->getPayment()->getPanno(); $dd_no = $order->getPayment()->getDdNo(); $dd_date = $order->getPayment()->getDdDate(); $draweenamedd = $order->getPayment()->getDraweenamedd(); $draweebankdd = $order->getPayment()->getDraweebankdd(); // Create new PDF $pdf = new Zend_Pdf(); //Mage::log(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'frontend/sm_market/default/images/pdf/cheque.jpg'); // Add new page to the document $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE); // define font resource $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); // set font for page // write text to page // $page->setFont($font, 24) // ->drawText('That which we call a rose,', 72, 720) // ->drawText('By any other name would smell as sweet.', 72, 620); $pdf->pages[] = $page; if ($payment_method_code == 'paymentmodulepackbankin') { $image = Zend_Pdf_Image::imageWithPath('skin/frontend/default/msupply/images/pdf/dd.jpg'); $page->drawImage($image, 50, 100, 772, 496); $page->setFont($font, 10)->drawText($companyname, 142, 418); $page->setFont($font, 10)->drawText($clientcode, 120, 355); // $page->setFont($font,10)->drawText($local,160,385); // $page->setFont($font,10)->drawText($out,380,385); $page->setFont($font, 10)->drawText($currentdate, 310, 355); $page->setFont($font, 10)->drawText($original_deposit_id, 648, 385); $page->setFont($font, 10)->drawText($customername, 140, 323); //$page->setFont($font,10)->drawText('HSR Layout, Bangalore',470,267); $page->setFont($font, 10)->drawText($dd_no, 97, 276); $page->setFont($font, 10)->drawText($dd_date, 220, 276); $page->setFont($font, 10)->drawText($draweenamedd, 280, 276); $page->setFont($font, 10)->drawText($draweebankdd, 425, 276); $page->setFont($font, 10)->drawText($order_ic_id, 570, 276); $page->setFont($font, 10)->drawText('Rs. ' . $grandtotal, 685, 276); $page->setFont($font, 10)->drawText('Rs. ' . $total, 683, 178); } if ($payment_method_code == 'cheque_checkout') { $image = Zend_Pdf_Image::imageWithPath('skin/frontend/default/msupply/images/pdf/cheque.jpg'); $page->drawImage($image, 50, 100, 772, 496); $page->setFont($font, 10)->drawText($companyname, 152, 418); $page->setFont($font, 10)->drawText($clientcode, 135, 353); $page->setFont($font, 10)->drawText($local, 125, 385); $page->setFont($font, 10)->drawText($out, 368, 385); $page->setFont($font, 10)->drawText($currentdate, 322, 353); $page->setFont($font, 10)->drawText($original_deposit_id, 630, 385); $page->setFont($font, 10)->drawText($customername, 155, 322); $page->setFont($font, 10)->drawText($checkno, 110, 276); $page->setFont($font, 10)->drawText($chqdate, 230, 276); $page->setFont($font, 10)->drawText($draweename, 300, 276); $page->setFont($font, 10)->drawText($draweebank, 430, 276); $page->setFont($font, 10)->drawText($order_ic_id, 560, 276); $page->setFont($font, 10)->drawText('Rs. ' . $grandtotal, 675, 276); $page->setFont($font, 10)->drawText('Rs. ' . $total, 675, 178); } if ($payment_method_code == 'cashin') { $image = Zend_Pdf_Image::imageWithPath('skin/frontend/default/msupply/images/pdf/cashin.jpg'); $page->drawImage($image, 50, 100, 772, 496); $page->setFont($font, 10)->drawText($companyname, 165, 418); $page->setFont($font, 10)->drawText($clientcode, 148, 355); //$page->setFont($font,10)->drawText($localchq,160,368); $page->setFont($font, 10)->drawText($currentdate, 326, 355); $page->setFont($font, 10)->drawText($original_deposit_id, 580, 386); $page->setFont($font, 10)->drawText($customername, 173, 323); $page->setFont($font, 10)->drawText($order_ic_id, 645, 276); $page->setFont($font, 10)->drawText('Rs. ' . $total, 535, 160); } $pdfData = $pdf->render(); $fileName = $order_ic_id . '.pdf'; $this->_prepareDownloadResponse($fileName, $pdfData); }
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 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; }
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); } }
public function pdfdisplayAction() { $date1 = $this->_request->getParam('date1'); $date2 = $this->_request->getParam('date2'); $glsubcode = $this->_request->getParam('ledger'); $pdf = new Zend_Pdf(); $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4); $pdf->pages[] = $page; $app = $this->view->baseUrl(); $word = explode('/', $app); $projname = $word[1]; //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, 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 //set the font $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 8); $this->view->search = 10; $generalLedger = new Generalledger_Model_Generalledger(); //Lia $this->view->ledegerList = $generalLedger->generalLedger($date1, $date2, $glsubcode); $openingCash = $generalLedger->openingBalance($date1, $glsubcode); print_r($openingCash); // // Assets $this->view->ledegerListAssets = $generalLedger->generalLedgerAssets($date1, $date2, $glsubcode); $this->view->openingCashAssets = $generalLedger->openingBalanceAssets($date1, $glsubcode); if (!$this->view->ledegerListAssets && !$this->view->openingCashAssets) { } else { $this->view->search = 0; echo "<font color='red'><b> Record not found</b> </font>"; } if (count($openingCash)) { foreach ($openingCash as $openingCash) { if ($openingCash["glsubcode_id"] == $ledegerList["glsubcode_id"]) { $liabilityCash = $openingCash["openingCash"]; } } } $text = array("Particular", "debit", "credit", "balance", "Opening balance"); $x0 = 60; $x1 = 200; $x2 = 340; $x3 = 480; $page->drawLine(50, 740, 550, 740); $page->drawLine(50, 720, 550, 720); $page->drawText($text[0], $x0, 725); $page->drawText($text[1], $x1, 725); $page->drawText($text[2], $x2, 725); $page->drawText($text[3], $x3, 725); $page->drawText($text[4], $x0, 700); foreach ($openingCash as $openingCash) { $page->drawText($openingCash["openingCash"], $x3, 700); } $y1 = 725; //$page->drawText(Opening balance,$x0, $y1); $pdf->save('/var/www/' . $projname . '/reports/GL.pdf'); $path = '/var/www/' . $projname . '/reports/GL.pdf'; // $pdf->save('/var/www/ourbank/reports/GL.pdf'); // $path = '/var/www/ourbank/reports/GL.pdf'; chmod($path, 0777); }
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; }
$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) ->setFillColor(Zend_Pdf_Color_Html::color('#9999cc')) ->drawText('Helvetica 36 text string', 60, 500); // Use font object for another page $page2->setFont($font, 24) ->drawText('Helvetica 24 text string', 60, 500); // Use another font $page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32) ->drawText('Times-Roman 32 text string', 60, 450); // Draw rectangle $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8)) ->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)) ->setLineDashingPattern(array(3, 2, 3, 4), 1.6) ->drawRectangle(60, 400, 400, 350); // Draw circle $page2->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID) ->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0)) ->drawCircle(85, 375, 25); // Draw sectors $page2->drawCircle(200, 375, 25, 2*M_PI/3, -M_PI/6)
/** * 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 }
/** * Create new page and assign to PDF object * * @param array $settings Page Settings * @return Zend_Pdf_Page */ public function newPage(array $settings = array()) { /* Add new table head */ $page = $this->_getPdf()->newPage(Zend_Pdf_Page::SIZE_A4); $this->_getPdf()->pages[] = $page; $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); $page->setFont($font, 11); $this->y = 800; return $page; }