Exemplo n.º 1
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');
 }
Exemplo n.º 2
0
 /**
  * Extension of basic draw-text function to allow it to vertically center text
  *
  * @param Zend_Pdf_Page $page
  * @param string $text
  * @param int $x1
  * @param int $y1
  * @param int $x2
  * @param int $position
  * @param string $encoding
  * @return self
  */
 public function drawText3(Zend_Pdf_Page $page, $text, $x1, $y1, $x2 = null, $position = self::TEXT_ALIGN_LEFT, $encoding = null)
 {
     die("RUN2");
     print "lib";
     $bottom = $y1;
     // could do the same for vertical-centering
     switch ($position) {
         case self::TEXT_ALIGN_LEFT:
             $left = $x1;
             break;
         case self::TEXT_ALIGN_RIGHT:
             $text_width = $this->getTextWidth($text, $page->getFont(), $page->getFontSize());
             $left = $x1 - $text_width;
             break;
         case self::TEXT_ALIGN_CENTER:
             if (null === $x2) {
                 throw new Exception("Cannot center text horizontally, x2 is not provided");
             }
             $text_width = $this->getTextWidth($text, $page->getFont(), $page->getFontSize());
             $box_width = $x2 - $x1;
             $left = $x1 + ($box_width - $text_width) / 2;
             break;
         default:
             throw new Exception("Invalid position value \"{$position}\"");
     }
     print "drawText({$line}, {$left}, {$bottom} - 0 * " . $page->getFontSize() . ", {$encoding});";
     // display multi-line text
     foreach (explode(PHP_EOL, $text) as $i => $line) {
         $page->drawText($line, $left, $bottom - $i * $page->getFontSize(), $encoding);
     }
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Add Piece Number
  *
  * @param int $pieceNumber
  * @param int $piecesTotal
  * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder
  * @throws InvalidArgumentException
  * @throws Zend_Pdf_Exception
  */
 public function addPieceNumber($pieceNumber, $piecesTotal)
 {
     $this->_page->saveGS();
     if (!$pieceNumber || !$piecesTotal) {
         throw new InvalidArgumentException(Mage::helper('usa')->__('Piece number information is missing'));
     }
     $this->_page->setFont($this->_fontNormal, 6);
     $this->_page->drawText('Piece:', $this->_x(256), $this->_y(224));
     $this->_page->setFont($this->_fontBold, 11);
     $this->_page->drawText($pieceNumber . '/' . $piecesTotal, $this->_x(256), $this->_y(234));
     $this->_page->restoreGS();
     return $this;
 }
 protected function _drawHeader(Zend_Pdf_Page $page)
 {
     $font = $page->getFont();
     $size = $page->getFontSize();
     $page->drawText(Mage::helper('sales')->__('Products'), $x = 35, $this->y, 'UTF-8');
     $x += 220;
     $page->drawText(Mage::helper('sales')->__('SKU'), $x, $this->y, 'UTF-8');
     $x += 100;
     $text = Mage::helper('sales')->__('Total (ex)');
     $page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
     $x += 50;
     $text = Mage::helper('sales')->__('Discount');
     $page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
     $x += 50;
     $text = Mage::helper('sales')->__('Qty');
     $page->drawText($text, $this->getAlignCenter($text, $x, 30, $font, $size), $this->y, 'UTF-8');
     $x += 30;
     $text = Mage::helper('sales')->__('Tax');
     $page->drawText($text, $this->getAlignRight($text, $x, 45, $font, $size, 10), $this->y, 'UTF-8');
     $x += 45;
     $text = Mage::helper('sales')->__('Total (inc)');
     $page->drawText($text, $this->getAlignRight($text, $x, 570 - $x, $font, $size), $this->y, 'UTF-8');
 }
Exemplo n.º 5
0
 protected function _printComments($order, Zend_Pdf_Page $page)
 {
     if (Mage::helper('core')->isModuleEnabled('Magemaven_OrderComment') && ($order->getCustomerComment() || $order->getCustomerNote())) {
         $comment = Mage::helper('ordercomment')->escapeHtml($order->getCustomerComment() ? $order->getCustomerComment() : $order->getCustomerNote());
         $this->y -= 15;
         $page->drawText(Mage::helper('ordercomment')->__('Order Comment'), 35, $this->y, 'UTF-8');
         $this->y -= 15;
         $leftToPrint = explode(' ', $comment);
         $availableWidth = $page->getWidth();
         while (!empty($leftToPrint)) {
             $currentLine = $leftToPrint;
             $leftToPrint = array();
             while ($this->widthForStringUsingFontSize(implode(' ', $currentLine), $page->getFont(), $page->getFontSize()) > $availableWidth) {
                 $leftToPrint[] = array_pop($currentLine);
             }
             $page->drawText(implode(' ', $currentLine), 35, $this->y, 'UTF-8');
         }
     }
 }
 protected function drawFont($object)
 {
     $fontItem = $object->getItem();
     if ($fontItem->getFace() == 'bold') {
         $fontDecoration = 'bold';
     } else {
         $fontDecoration = 'regular';
     }
     $fontPath = SERVER_BASE . '/fonts/' . $fontItem->getName() . '.ttf';
     if (is_file($fontPath)) {
         $font = Zend_Pdf_Font::fontWithPath($fontPath, Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION);
     } else {
         if ($fontDecoration == "bold") {
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
         } else {
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
         }
     }
     if ($fontItem->getFace() == "invert") {
         $this->page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
         //schwarze farbe setzen fuer Hintergrund
         $width = $this->widthForStringUsingFontSize($object->getValue(), $font, $fontItem->getSize());
         $height = $fontItem->getSize();
         $this->page->drawRectangle($this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy())) + $height / 2, $this->coordX($this->mmToPts($object->getPosx())) + $width, $this->coordY($this->mmToPts($object->getPosy())) - $height / 2, Zend_Pdf_Page::SHAPE_DRAW_FILL);
         $this->page->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 1));
         //weiße farbe setzen fuer Text
     } else {
         $this->page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
         //schwarze farbe setzen fuer text
     }
     $this->page->setFont($font, $fontItem->getSize());
     if ($fontItem->getRotation() !== null) {
         $this->page->rotate($this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy())), deg2rad(360 - $fontItem->getRotation()));
     }
     $this->page->drawText($object->getValue(), $this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy()) + $fontItem->getSize() / 2), 'UTF-8');
     if ($fontItem->getRotation() !== null) {
         $this->page->rotate($this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy())), -deg2rad(360 - $fontItem->getRotation()));
     }
 }
Exemplo n.º 7
0
 public function testPageCloning()
 {
     $pdf = Zend_Pdf::load(dirname(__FILE__) . '/_files/pdfarchiving.pdf');
     $srcPageCount = count($pdf->pages);
     try {
         $newPage = clone reset($pdf->pages);
     } catch (Zend_Pdf_Exception $e) {
         if (strpos($e->getMessage(), 'Cloning Zend_Pdf_Page object using \'clone\' keyword is not supported.') !== 0) {
             throw $e;
         }
         // Exception is thrown
     }
     $outputPageSet = array();
     foreach ($pdf->pages as $srcPage) {
         $page = new Zend_Pdf_Page($srcPage);
         $outputPageSet[] = $srcPage;
         $outputPageSet[] = $page;
         $page->saveGS();
         // Create new Style
         $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0.9))->setLineColor(new Zend_Pdf_Color_GrayScale(0.2))->setLineWidth(3)->setLineDashingPattern(array(3, 2, 3, 4), 1.6)->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32);
         $page->rotate(0, 0, M_PI_2 / 3);
         $page->drawText('Modified by Zend Framework!', 150, 0);
         $page->restoreGS();
     }
     // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
     $pdf->pages = $outputPageSet;
     $pdf->save(dirname(__FILE__) . '/_files/output.pdf');
     unset($pdf);
     $pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
     $this->assertTrue($pdf1 instanceof Zend_Pdf);
     $this->assertEquals($srcPageCount * 2, count($pdf1->pages));
     unset($pdf1);
     unlink(dirname(__FILE__) . '/_files/output.pdf');
 }
Exemplo n.º 8
0
 /**
  * Add the token to a pdf page
  *
  * @param \Zend_Pdf_Page $page
  * @param string $tokenId
  */
 protected function addTokenToPage(\Zend_Pdf_Page $page, $tokenId)
 {
     // Set $this->pageFont to false to prevent drawing of tokens on page.
     if ($this->pageFont) {
         $font = \Zend_Pdf_Font::fontWithName($this->pageFont);
         if ($this->pageXfromLeft) {
             $x = $this->pageX;
         } else {
             $x = $page->getWidth() - $this->pageX;
         }
         if ($this->pageYfromTop) {
             $y = $page->getHeight() - $this->pageY;
         } else {
             $y = $this->pageY;
         }
         $page->setFont($font, $this->pageFontSize);
         $page->drawText(strtoupper($tokenId), $x, $y, 'UTF-8');
     }
 }
Exemplo n.º 9
0
 protected static function DrawHeader(Zend_Pdf_Page $objPage)
 {
     $intY = STEWARDSHIP_TOP - 5 / 8 * 72;
     $intY -= 13.2;
     $objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12);
     $objPage->drawText(STEWARDSHIP_STATEMENT_LINE_1, 36, $intY, 'UTF-8');
     $intY -= 9.199999999999999;
     $objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 8);
     $objPage->drawText(STEWARDSHIP_STATEMENT_LINE_2, 36, $intY, 'UTF-8');
     $intY -= 12.1;
     $objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 11);
     $objPage->drawText(STEWARDSHIP_STATEMENT_LINE_3, 36, $intY, 'UTF-8');
     $intY -= 12.1;
     $objPage->drawText(STEWARDSHIP_STATEMENT_LINE_4, 36, $intY, 'UTF-8');
     if (!self::$ZendImage) {
         self::$ZendImage = Zend_Pdf_Image::imageWithPath(__DOCROOT__ . __IMAGE_ASSETS__ . '/alcf_logo_stewardship.png');
     }
     $objPage->drawImage(self::$ZendImage, 424, STEWARDSHIP_TOP - 108, 576, STEWARDSHIP_TOP - 36);
 }
Exemplo n.º 10
0
$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);
Exemplo n.º 11
0
 /**
  * Draw one line - rma item
  *
  * @param Enterprise_Rma_Model_Item $item
  * @param Zend_Pdf_Page $page
  */
 protected function _drawRmaItem($item, $page)
 {
     $shift = 0;
     foreach (Mage::helper('core/string')->str_split($item->getProductName(), 40, true, true) as $key => $part) {
         $page->drawText($part, $this->getProductNameX(), $this->y - $shift, 'UTF-8');
         $shift += 10;
     }
     $shift = 0;
     foreach (Mage::helper('core/string')->str_split($item->getProductSku(), 18) as $key => $part) {
         $page->drawText($part, $this->getProductSkuX(), $this->y - $shift, 'UTF-8');
         $shift += 10;
     }
     $condition = Mage::helper('core/string')->str_split($this->_getOptionAttributeStringValue($item->getCondition()), 25);
     $page->drawText($condition[0], $this->getConditionX(), $this->y, 'UTF-8');
     $resolution = Mage::helper('core/string')->str_split($this->_getOptionAttributeStringValue($item->getResolution()), 25);
     $page->drawText($resolution[0], $this->getResolutionX(), $this->y, 'UTF-8');
     $page->drawText(Mage::helper('enterprise_rma')->parseQuantity($item->getQtyRequested(), $item), $this->getQtyRequestedX(), $this->y, 'UTF-8');
     $page->drawText(Mage::helper('enterprise_rma')->getQty($item), $this->getQtyX(), $this->y, 'UTF-8');
     $status = Mage::helper('core/string')->str_split($item->getStatusLabel(), 25);
     $page->drawText($status[0], $this->getStatusX(), $this->y, 'UTF-8');
     $productOptions = $item->getOptions();
     if (is_array($productOptions) && !empty($productOptions)) {
         $this->_drawCustomOptions($productOptions, $page);
     }
     $this->y -= 10;
 }
Exemplo n.º 12
0
 public function drawText($text, $x, $y, $charEncoding = 'UTF-8')
 {
     parent::drawText($text, $x, $y, 'UTF-8');
     return $this;
 }
Exemplo n.º 13
0
<?php

header('Content-Type: application/x-pdf');
header("Content-Disposition: attachment;filename=invoice.pdf");
header("Cache-Control: no-cache, must-revalidate");
$path = dirname(dirname(__FILE__)) . '/library';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once "Zend/Pdf.php";
$pdf = new Zend_Pdf();
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER);
$pdf->pages[] = $page;
$pdf->pages[] = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
$page->setFont($font, 12);
$page->drawText('wewe', 110, 641);
//echo $page->getHeight();
//echo $page->getWidth();
$pdf->save("report2.pdf");
header('Location: report2.pdf');
 protected function _drawHeader(Zend_Pdf_Page $page, $order)
 {
     if ($order instanceof Mage_Sales_Model_Order && (!$order->getDcOrderId() || $order->getDeliveryDutyType() == Dutycalculator_Charge_Helper_Data::DC_DELIVERY_TYPE_DDU || $order->getFailedCalculation())) {
         $font = $page->getFont();
         $size = $page->getFontSize();
         $page->drawText(Mage::helper('sales')->__('Products'), $x = 35, $this->y, 'UTF-8');
         $x += 220;
         $page->drawText(Mage::helper('sales')->__('SKU'), $x, $this->y, 'UTF-8');
         $x += 100;
         $text = Mage::helper('sales')->__('Total (ex)');
         $page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
         $x += 50;
         $text = Mage::helper('sales')->__('Discount');
         $page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
         $x += 50;
         $text = Mage::helper('sales')->__('Qty');
         $page->drawText($text, $this->getAlignCenter($text, $x, 30, $font, $size), $this->y, 'UTF-8');
         $x += 30;
         $text = Mage::helper('sales')->__('Tax');
         $page->drawText($text, $this->getAlignRight($text, $x, 45, $font, $size, 10), $this->y, 'UTF-8');
         $x += 45;
         $text = Mage::helper('sales')->__('Total (inc)');
         $page->drawText($text, $this->getAlignRight($text, $x, 570 - $x, $font, $size), $this->y, 'UTF-8');
     } else {
         $font = $page->getFont();
         $size = $page->getFontSize();
         $page->drawText(Mage::helper('sales')->__('Products'), $x = 35, $this->y, 'UTF-8');
         $x += 200;
         //220
         $page->drawText(Mage::helper('sales')->__('SKU'), $x, $this->y, 'UTF-8');
         $x += 80;
         //100
         $text = Mage::helper('sales')->__('Total (ex)');
         $page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
         $x += 50;
         $text = Mage::helper('sales')->__('Discount');
         $page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
         $x += 50;
         $text = Mage::helper('sales')->__('Qty');
         $page->drawText($text, $this->getAlignCenter($text, $x, 30, $font, $size), $this->y, 'UTF-8');
         $x += 30;
         $text = Mage::helper('dccharge')->__('Sales Tax');
         $page->drawText($text, $this->getAlignRight($text, $x, 40, $font, $size, 10), $this->y, 'UTF-8');
         $x += 40;
         //45
         $text = Mage::helper('dccharge')->__('Import Duty');
         $page->drawText($text, $this->getAlignRight($text, $x, 45, $font, $size, 10), $this->y, 'UTF-8');
         $x += 45;
         //45
         $text = Mage::helper('sales')->__('Total (inc)');
         $page->drawText($text, $this->getAlignRight($text, $x, 570 - $x, $font, $size), $this->y, 'UTF-8');
     }
 }
 public function downloadAction()
 {
     if ($this->_loadValidVoucher()) {
         $voucherCode = $this->getRequest()->getParam('code');
         $text = Mage::helper('voucher');
         $_product = Mage::registry('current_product');
         $pdf = new Zend_Pdf();
         $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER);
         $pageHeight = $page->getHeight();
         $pageWidth = $page->getWidth();
         //$page->rotate(($pageWidth/2), ($pageHeight/2), 1);
         $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
         $logoImage = Zend_Pdf_Image::imageWithPath(Mage::getDesign()->getSkinBaseDir() . '/images/logo_small_en.jpg');
         //$footerImage = Zend_Pdf_Image::imageWithPath(Mage::getDesign()->getSkinBaseDir() . '/images/voucher_footer_en.png'); //VD
         $productImage = Zend_Pdf_Image::imageWithPath(Mage::getBaseDir() . '/media/catalog/product' . $_product->getVoucherImage());
         //$footerImageHeight = $footerImage->getPixelHeight();  //VD
         //$footerImageWidth = $footerImage->getPixelWidth();  //VD
         $logoImageHeight = 75;
         //VDEdit
         $logoImageWidth = 250;
         //VDEdit
         $tableWidth = 568;
         $startPoint = ($pageWidth - $tableWidth) / 2;
         $endPoint = $startPoint + $tableWidth;
         $botPoint = 10;
         $topPoint = $pageHeight - 30;
         $page->setLineWidth('0.3')->setLineDashingPattern(array(3, 3, 3, 3))->drawLine($startPoint, $topPoint, $startPoint, $botPoint)->drawLine($endPoint, $topPoint, $endPoint, $botPoint)->drawLine($startPoint, $topPoint, $endPoint, $topPoint)->drawLine($startPoint, $botPoint, $endPoint, $botPoint)->drawLine($startPoint, $pageHeight - $logoImageHeight - 235, $endPoint, $pageHeight - $logoImageHeight - 235)->drawLine($startPoint, $pageHeight - $logoImageHeight - 235 - 325, $endPoint, $pageHeight - $logoImageHeight - 235 - 325);
         $page->setFillColor(Zend_Pdf_Color_Html::color('#16599D'))->drawRectangle($startPoint + 2, $topPoint - $logoImageHeight - 2, $endPoint, $topPoint);
         $page->drawImage($logoImage, $startPoint, $topPoint - $logoImageHeight - 1, $startPoint + $logoImageWidth, $topPoint);
         //$page->drawImage($footerImage, $startPoint + 2, $botPoint, $startPoint + $footerImageWidth - 20, $botPoint + $footerImageHeight);
         $page->drawImage($productImage, $startPoint + 7, $topPoint - 55 - $productImage->getPixelHeight(), $startPoint + 7 + 246, $topPoint - 55 - $productImage->getPixelHeight() + 165);
         $page->setFillColor(Zend_Pdf_Color_Html::color('#FFFFFF'))->setLineDashingPattern(array(1, 0, 1, 0))->drawRectangle($endPoint - 205, $topPoint - 10, $endPoint - 15, $topPoint + 10)->setLineDashingPattern(array(0, 1000, 0, 1000))->setFillColor(Zend_Pdf_Color_Html::color('#EDF4FA'))->drawRectangle($startPoint + 0.3, $pageHeight - $logoImageHeight - 235, $endPoint, $pageHeight - $logoImageHeight - 235 - 325);
         $style = new Zend_Pdf_Style();
         $style->setFont($font, 15);
         $page->setFont($font, 12)->setFillColor(Zend_Pdf_Color_Html::color('#000000'))->drawText($text->__('Voucher Code: ' . $voucherCode), $endPoint - 193, $topPoint - 4)->setFont($font, 15);
         $lines = explode("\n", $this->getWrappedText($text->__('Voucher for ') . $_product->getName(), $style, 270));
         //var_dump($lines);
         foreach ($lines as $k => $line) {
             $page->drawText($line, $startPoint + $productImage->getPixelWidth() + 20, $topPoint - 70 - $k * 20);
         }
         //
         $pdf->pages[0] = $page;
         $pdf->save(Mage::getBaseDir() . '/media/vouchers/' . $voucherCode . '.pdf');
         $this->getResponse()->clearHeaders()->setHeader('content-type:', 'Application/pdf')->setHeader('Content-Type', 'application/force-download')->setHeader('Content-Disposition', 'attachment; filename="' . $voucherCode . '.pdf"')->setBody($pdf->render());
     }
 }
 /**
  * Apply stamp on one page with given style.
  * 
  * @param Zend_Pdf_Page  $page
  * @param Zend_Pdf_Style $style
  * @param String         $stamp
  * 
  * @return void
  */
 protected function stampOnePage($page, $style, $stamp)
 {
     $height = $page->getHeight();
     $page->setStyle($style);
     $page->drawRectangle(40, 40, 60, $height - 40, Zend_Pdf_Page::SHAPE_DRAW_STROKE);
     $page->rotate(20, 20, 1.57);
     $page->drawText($stamp, 50, -10);
 }
Exemplo n.º 17
0
 /**
  * Draw packages block
  *
  * @param  \Zend_Pdf_Page $page
  * @return \Magento\Shipping\Model\Order\Pdf\Packaging
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 protected function _drawPackageBlock(\Zend_Pdf_Page $page)
 {
     if ($this->getPackageShippingBlock()) {
         $packaging = $this->getPackageShippingBlock();
     } else {
         $packaging = $this->_layout->getBlockSingleton('Magento\\Shipping\\Block\\Adminhtml\\Order\\Packaging');
     }
     $packages = $packaging->getPackages();
     $packageNum = 1;
     foreach ($packages as $package) {
         $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->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
         $page->drawRectangle(520, $this->y + 15, 570, $this->y - 5);
         $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
         $packageText = __('Package') . ' ' . $packageNum;
         $page->drawText($packageText, 525, $this->y, 'UTF-8');
         $packageNum++;
         $package = new \Magento\Framework\DataObject($package);
         $params = new \Magento\Framework\DataObject($package->getParams());
         $dimensionUnits = $this->_carrierHelper->getMeasureDimensionName($params->getDimensionUnits());
         $typeText = __('Type') . ' : ' . $packaging->getContainerTypeByCode($params->getContainer());
         $page->drawText($typeText, 35, $this->y, 'UTF-8');
         if ($params->getLength() != null) {
             $lengthText = $params->getLength() . ' ' . $dimensionUnits;
         } else {
             $lengthText = '--';
         }
         $lengthText = __('Length') . ' : ' . $lengthText;
         $page->drawText($lengthText, 200, $this->y, 'UTF-8');
         if ($params->getDeliveryConfirmation() != null) {
             $confirmationText = __('Signature Confirmation') . ' : ' . $packaging->getDeliveryConfirmationTypeByCode($params->getDeliveryConfirmation());
             $page->drawText($confirmationText, 355, $this->y, 'UTF-8');
         }
         $this->y = $this->y - 10;
         if ($packaging->displayCustomsValue() != null) {
             $customsValueText = __('Customs Value') . ' : ' . $packaging->displayPrice($params->getCustomsValue());
             $page->drawText($customsValueText, 35, $this->y, 'UTF-8');
         }
         if ($params->getWidth() != null) {
             $widthText = $params->getWidth() . ' ' . $dimensionUnits;
         } else {
             $widthText = '--';
         }
         $widthText = __('Width') . ' : ' . $widthText;
         $page->drawText($widthText, 200, $this->y, 'UTF-8');
         if ($params->getContentType() != null) {
             if ($params->getContentType() == 'OTHER') {
                 $contentsValue = $params->getContentTypeOther();
             } else {
                 $contentsValue = $packaging->getContentTypeByCode($params->getContentType());
             }
             $contentsText = __('Contents') . ' : ' . $contentsValue;
             $page->drawText($contentsText, 355, $this->y, 'UTF-8');
         }
         $this->y = $this->y - 10;
         $weightText = __('Total Weight') . ' : ' . $params->getWeight() . ' ' . $this->_carrierHelper->getMeasureWeightName($params->getWeightUnits());
         $page->drawText($weightText, 35, $this->y, 'UTF-8');
         if ($params->getHeight() != null) {
             $heightText = $params->getHeight() . ' ' . $dimensionUnits;
         } else {
             $heightText = '--';
         }
         $heightText = __('Height') . ' : ' . $heightText;
         $page->drawText($heightText, 200, $this->y, 'UTF-8');
         $this->y = $this->y - 10;
         if ($params->getSize()) {
             $sizeText = __('Size') . ' : ' . ucfirst(strtolower($params->getSize()));
             $page->drawText($sizeText, 35, $this->y, 'UTF-8');
         }
         if ($params->getGirth() != null) {
             $dimensionGirthUnits = $this->_carrierHelper->getMeasureDimensionName($params->getGirthDimensionUnits());
             $girthText = __('Girth') . ' : ' . $params->getGirth() . ' ' . $dimensionGirthUnits;
             $page->drawText($girthText, 200, $this->y, 'UTF-8');
         }
         $this->y = $this->y - 5;
         $page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
         $page->drawRectangle(25, $this->y, 570, $this->y - 30 - count($package->getItems()) * 12);
         $this->y = $this->y - 10;
         $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
         $page->drawText(__('Items in the Package'), 30, $this->y, 'UTF-8');
         $txtIndent = 5;
         $itemCollsNumber = $packaging->displayCustomsValue() ? 5 : 4;
         $itemCollsX[0] = 30;
         //  coordinate for Product name
         $itemCollsX[1] = 250;
         // coordinate for Product name
         $itemCollsXEnd = 565;
         $itemCollsXStep = round(($itemCollsXEnd - $itemCollsX[1]) / ($itemCollsNumber - 1));
         // calculate coordinates for all other cells (Weight, Customs Value, Qty Ordered, Qty)
         for ($i = 2; $i <= $itemCollsNumber; $i++) {
             $itemCollsX[$i] = $itemCollsX[$i - 1] + $itemCollsXStep;
         }
         $i = 0;
         $page->setFillColor(new \Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsX[++$i], $this->y - 15);
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsX[++$i], $this->y - 15);
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsX[++$i], $this->y - 15);
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsX[++$i], $this->y - 15);
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsXEnd, $this->y - 15);
         $this->y = $this->y - 12;
         $i = 0;
         $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
         $page->drawText(__('Product'), $itemCollsX[$i] + $txtIndent, $this->y, 'UTF-8');
         $page->drawText(__('Weight'), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         if ($packaging->displayCustomsValue()) {
             $page->drawText(__('Customs Value'), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         }
         $page->drawText(__('Qty Ordered'), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         $page->drawText(__('Qty'), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         $i = 0;
         foreach ($package->getItems() as $itemId => $item) {
             $item = new \Magento\Framework\DataObject($item);
             $i = 0;
             $page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsX[++$i], $this->y - 15);
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsX[++$i], $this->y - 15);
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsX[++$i], $this->y - 15);
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsX[++$i], $this->y - 15);
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsXEnd, $this->y - 15);
             $this->y = $this->y - 12;
             $i = 0;
             $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
             $page->drawText($item->getName(), $itemCollsX[$i] + $txtIndent, $this->y, 'UTF-8');
             $page->drawText($item->getWeight(), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
             if ($packaging->displayCustomsValue()) {
                 $page->drawText($packaging->displayPrice($item->getCustomsValue()), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
             }
             $page->drawText($packaging->getQtyOrderedItem($item->getOrderItemId()), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
             $page->drawText($item->getQty() * 1, $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         }
         $this->y = $this->y - 30;
     }
     return $this;
 }
Exemplo n.º 18
0
 function pdfdisplayAction()
 {
     $convertdate = new App_Model_dateConvertor();
     //  echo '<pre>'; print_r($this->_request->getParam('accNum'));
     $this->view->details = $this->view->loanModel->searchaccounts($this->_request->getParam('accNum'));
     //echo '<pre>'; print_r($this->view->details);
     $this->view->tran = $this->view->loanModel->loanInstalments($this->_request->getParam('accNum'));
     $this->view->paid = $this->view->loanModel->paid($this->_request->getParam('accNum'));
     $this->view->unpaid = $this->view->loanModel->unpaid($this->_request->getParam('accNum'));
     // 		$loansearch = new Loandetailsg_Form_Search();
     // 		$loantransactions = new Loandisbursmentg_Model_loan();
     $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, 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);
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $page->drawText('( LOAN LEDGER )', 237, 780);
     $text = array("Member details");
     $x0 = 50;
     $x3 = 310;
     $x1 = 150;
     $x2 = 220;
     $page->drawLine(50, 740, 290, 740);
     $page->drawLine(50, 720, 290, 720);
     $page->drawText($text[0], 90, 727);
     $y1 = 700;
     foreach ($this->view->details as $details) {
         $page->drawText('Name  : ' . $details->name, $x0, $y1);
         $y1 = $y1 - 20;
         $page->drawText('Branch  : ' . $details->officename, $x0, $y1);
         $y1 = $y1 - 20;
         $page->drawText('Code  : ' . $details->code, $x0, $y1);
         $y1 = $y1 - 20;
         $page->drawText('Account code  : ' . $details->number, $x0, $y1);
         $text1 = array("Loan details");
         $y1 = $y1 - 25;
         $page->drawLine(50, $y1, 290, $y1);
         $y1 = $y1 - 20;
         $page->drawLine(50, $y1, 290, $y1);
         $y1 = $y1 + 7;
         $page->drawText($text1[0], 90, $y1);
         $y1 = $y1 - 25;
         $page->drawText('Loan name  : ' . $details->loanname, $x0, $y1);
         $y1 = $y1 - 20;
         $page->drawText('Loan amount Rs  : ' . $details->amount, $x0, $y1);
         $y1 = $y1 - 20;
         $page->drawText('Interest rate %  : ' . $details->interest, $x0, $y1);
         $y1 = $y1 - 20;
         $page->drawText('Installments  : ' . $details->installments, $x0, $y1);
         $y1 = $y1 - 20;
         $page->drawText('Sanctioned date  : ' . $details->sanctioned, $x0, $y1);
         $y1 = $y1 - 20;
     }
     $y1 = 740;
     $text2 = array("Installment status        No          Amount");
     $page->drawLine(310, $y1, 550, $y1);
     $y1 = $y1 - 20;
     $page->drawLine(310, $y1, 550, $y1);
     $y1 = $y1 + 7;
     $page->drawText($text2[0], $x3, $y1);
     foreach ($this->view->paid as $paid) {
         $y1 = $y1 - 25;
         $page->drawText('Paid' . $paid->paidAmt, 320, $y1);
         $page->drawText($paid->paidCount, 390, $y1);
     }
     foreach ($this->view->unpaid as $unpaid) {
         $y1 = $y1 - 20;
         $page->drawText('Due', 320, $y1);
         $page->drawText($unpaid->unpaidCount, 390, $y1);
         $page->drawText($unpaid->unpaidAmt, 430, $y1);
     }
     $y1 = 480;
     $text3 = array("GL.LF no            Transaction date           Creidt               Debit                      Payment mode              Transacted by ");
     $page->drawLine(50, $y1, 550, $y1);
     $y1 = $y1 - 20;
     $page->drawLine(50, $y1, 550, $y1);
     $y1 = $y1 + 7;
     $page->drawText($text3[0], $x0, $y1);
     foreach ($this->view->tran as $transaction) {
         $y1 = $y1 - 20;
         $page->drawText($transaction->id, 60, $y1);
         $page->drawText($transaction->date, 120, $y1);
         $page->drawText($transaction->cr, 160, $y1);
         $page->drawText($transaction->dt, 250, $y1);
         $page->drawText($transaction->mode, 330, $y1);
         $page->drawText($transaction->name, 420, $y1);
         $y1 = $y1 - 5;
         $page->drawLine(50, $y1, 550, $y1);
     }
     $pdf->pages[] = $page;
     $pdfData = $pdf->render();
     $pdf->save('/var/www/' . $projname . '/reports/loanledger.pdf');
     $path = '/var/www/' . $projname . '/reports/loanledger.pdf';
     chmod($path, 0777);
 }
Exemplo n.º 19
0
 /**
  * Wraps text on word boundaries and draws resulting text in consecutive
  * lines down from the origin point.
  *
  * @param string $text Text to draw
  * @param int $x X coordinate of origin on page
  * @param int $y Y coordinate of origin on page
  * @param int $wrapWidth Maximum width of a line
  */
 private function _drawWrappedText(Zend_Pdf_Page $page, $text, $x, $y, $wrapWidth)
 {
     $wrappedText = $this->_wrapText($text, $wrapWidth);
     $lines = explode("\n", $wrappedText);
     foreach ($lines as $line) {
         $page->drawText($line, $x, $y);
         $y -= self::FONT_SIZE + 5;
     }
 }
Exemplo n.º 20
0
 function drawSplittedText(Zend_Pdf_Page $page, 
                           $string,
                           $max_length,
                           $X,
                           &$Y){
   $chunks = str_split($string, $max_length);
   foreach ($chunks as $key=>$line) {
     $page->drawText($line, $X, $Y, 'UTF-8');
     $Y -= $this->getLineHeight();
   }
 }
Exemplo n.º 21
0
 /**
  * Draw Text
  * @param $text
  * @param $x
  * @param $y
  * @param string $charEncoding
  * @return Zend_Pdf_Canvas_Interface
  */
 public function drawText($text, $x, $y, $charEncoding = "utf-8")
 {
     return parent::drawText($text, $x, $y, $charEncoding);
 }
Exemplo n.º 22
0
 /**
  * Draw a line of text at the specified position.
  *
  * @param string $text
  * @param float $x
  * @param float $y
  * @param string $charEncoding (optional) Character encoding of source text.
  *   Defaults to current locale.
  * @param $align
  * @throws Zend_Pdf_Exception
  * @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page
  */
 public function drawText($text, $x, $y, $charEncoding = '', $align = self::ALIGN_LEFT)
 {
     $left = null;
     switch ($align) {
         case self::ALIGN_LEFT:
             $left = $x;
             break;
         case self::ALIGN_CENTER:
             $textWidth = $this->getTextWidth($text, $this->getFont(), $this->getFontSize());
             $left = $x - $textWidth / 2;
             break;
         case self::ALIGN_RIGHT:
             $textWidth = $this->getTextWidth($text, $this->getFont(), $this->getFontSize());
             $left = $x - $textWidth;
             break;
     }
     return parent::drawText($text, $left, $y, $charEncoding);
 }
Exemplo n.º 23
0
 /**
  * Draw text with wrapping and selected style
  *
  * @param string $text String
  * @param int $x x coordinate
  * @param int $y y coordinate
  * @param Zend_Pdf_Style $style Text style (font, size, color etc)
  * @param int $line_offset Line spacing
  * @param bool $force Use force wrapping
  *
  * @return int Current Y position
  *
  * @api
  */
 public function drawTextBlock($text, $x, $y, $style = NULL, $line_offset = 0, $force = false)
 {
     if ($style) {
         $s_y = $y;
         $this->saveGS();
         $lines = explode("\n", $this->getWrappedText($text, $style, $force));
         $this->setFont($style->getFont(), $style->getFontsize());
         foreach ($lines as $line) {
             $this->drawText(trim($line), $this->MARGIN['left'] + $x, $this->MARGIN['bottom'] + $y, 'UTF-8');
             $y -= $style->getFontsize() + $line_offset;
         }
         $this->restoreGS();
         // DEBUG
         //$this->drawHorizontalLine( $x, $x + $style->getLineWidth(), $s_y, $s_y-$y, new Zend_Pdf_Color_Html("red"));
         if ($this->currentPosition > $y - $this->MARGIN['bottom']) {
             $this->currentPosition = $y - $this->MARGIN['bottom'];
         }
         return $y;
     } else {
         return parent::drawText($text, $this->MARGIN['left'] + $x, $this->MARGIN['bottom'] + $y, 'UTF-8');
     }
 }