Example #1
0
 public function addNext($giftCard)
 {
     $template = $giftCard->getTemplate();
     if (!$template) {
         return false;
     }
     $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
     $draw = Mage::getModel('giftcard/giftcard_draw');
     $draw->setGiftCard($giftCard);
     $draw->setTemplate($template);
     $draw->drawGiftCard();
     if (!($imagePath = $draw->getImagePath())) {
         return false;
     }
     $image = Zend_Pdf_Image::imageWithPath($imagePath);
     $imgWidthPts = $image->getPixelWidth() * 72 / 96;
     $imgHeightPts = $image->getPixelHeight() * 72 / 96;
     $rate = $imgWidthPts / $page->getWidth();
     $imgWidthPts = $imgWidthPts / $rate;
     $imgHeightPts = $imgHeightPts / $rate;
     $pageHeight = $page->getHeight();
     $page->drawImage($image, 0, $pageHeight - $imgHeightPts, $imgWidthPts, $pageHeight);
     $this->addPage($page);
     unlink($imagePath);
     return true;
 }
Example #2
0
 /**
  * Create destination object
  *
  * @param Zend_Pdf_Page|integer $page  Page object or page number
  * @param float $left  Left edge of displayed page
  * @param float $top   Top edge of displayed page
  * @param float $zoom  Zoom factor
  * @return Zend_Pdf_Destination_Zoom
  * @throws Zend_Pdf_Exception
  */
 public static function create($page, $left = null, $top = null, $zoom = null)
 {
     $destinationArray = new Zend_Pdf_Element_Array();
     if ($page instanceof Zend_Pdf_Page) {
         $destinationArray->items[] = $page->getPageDictionary();
     } else {
         if (is_integer($page)) {
             $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
         } else {
             require_once 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
         }
     }
     $destinationArray->items[] = new Zend_Pdf_Element_Name('XYZ');
     if ($left === null) {
         $destinationArray->items[] = new Zend_Pdf_Element_Null();
     } else {
         $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
     }
     if ($top === null) {
         $destinationArray->items[] = new Zend_Pdf_Element_Null();
     } else {
         $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
     }
     if ($zoom === null) {
         $destinationArray->items[] = new Zend_Pdf_Element_Null();
     } else {
         $destinationArray->items[] = new Zend_Pdf_Element_Numeric($zoom);
     }
     return new Zend_Pdf_Destination_Zoom($destinationArray);
 }
Example #3
0
 /**
  * Draw Line for page
  *
  * @param Zend_Pdf_Page $page
  * @return void
  */
 protected function _drawLine(Zend_Pdf_Page $page)
 {
     //$this->_setFontRegular($page, 9);
     //$page->setLineColor(new Zend_Pdf_Color_GrayScale(0));
     $page->setLineWidth(1);
     $page->drawLine(25, $this->y - 15, 570, $this->y - 15);
 }
Example #4
0
 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();
 }
Example #5
0
 /**
  * Create destination object
  *
  * @param Zend_Pdf_Page|integer $page  Page object or page number
  * @return Zend_Pdf_Destination_FitBoundingBox
  * @throws Zend_Pdf_Exception
  */
 public static function create($page)
 {
     $destinationArray = new Zend_Pdf_Element_Array();
     if ($page instanceof Zend_Pdf_Page) {
         $destinationArray->items[] = $page->getPageDictionary();
     } elseif (is_integer($page)) {
         $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
     } else {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
     }
     $destinationArray->items[] = new Zend_Pdf_Element_Name('FitB');
     return new Zend_Pdf_Destination_FitBoundingBox($destinationArray);
 }
Example #6
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;
 }
 protected function drawDatamatrix($object)
 {
     $matrixItem = $object->getItem();
     $x = 214 / 2;
     // barcode center
     $y = 214 / 2;
     // barcode center
     $height = 40;
     // barcode height in 1D ; module size in 2D
     $width = 40;
     // barcode height in 1D ; not use in 2D
     // datamatrix creator expects iso 8859-1 code
     $code = str_replace("?", "|", $this->utf8ToIso88591($object->getValue()));
     $type = 'datamatrix';
     $im = imagecreatetruecolor(214, 214);
     $black = ImageColorAllocate($im, 0x0, 0x0, 0x0);
     $white = ImageColorAllocate($im, 0xff, 0xff, 0xff);
     imagefilledrectangle($im, 0, 0, 214, 214, $white);
     $data = $matrixItem::gd($im, $black, $x, $y, 0, $type, array('code' => $code));
     ob_start();
     imagepng($im);
     $imagestring = ob_get_contents();
     ob_end_clean();
     imagedestroy($im);
     $temp = tempnam(sys_get_temp_dir(), 'DMX');
     //tmpfile();
     $handle = fopen($temp, 'w+b');
     fwrite($handle, $imagestring);
     fseek($handle, 0);
     $image = new Zend_Pdf_Resource_Image_Png($temp);
     fclose($handle);
     //statt drawImage($image, $x1, $y1, $x2, $y2) nun drawImage($image, $x1, $y2, $x2, $y1)
     $this->page->drawImage($image, $this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy() + $matrixItem->getDimension())), $this->coordX($this->mmToPts($object->getPosx() + $matrixItem->getDimension())), $this->coordY($this->mmToPts($object->getPosy())));
 }
Example #8
0
 /**
  * Create destination object
  *
  * @param Zend_Pdf_Page|integer $page  Page object or page number
  * @param float $top  Top edge of displayed page
  * @return Zend_Pdf_Destination_FitHorizontally
  * @throws Zend_Pdf_Exception
  */
 public static function create($page, $top)
 {
     $destinationArray = new Zend_Pdf_Element_Array();
     if ($page instanceof Zend_Pdf_Page) {
         $destinationArray->items[] = $page->getPageDictionary();
     } else {
         if (is_integer($page)) {
             $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
         } else {
             require_once LIB_DIR . '/Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
         }
     }
     $destinationArray->items[] = new Zend_Pdf_Element_Name('FitH');
     $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
     return new Zend_Pdf_Destination_FitHorizontally($destinationArray);
 }
 /**
  * Create destination object
  *
  * @param Zend_Pdf_Page|integer $page  Page object or page number
  * @param float $left  Left edge of displayed page
  * @return Zend_Pdf_Destination_FitVertically
  * @throws Zend_Pdf_Exception
  */
 public static function create($page, $left)
 {
     $destinationArray = new Zend_Pdf_Element_Array();
     if ($page instanceof Zend_Pdf_Page) {
         $destinationArray->items[] = $page->getPageDictionary();
     } else {
         if (is_integer($page)) {
             $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
         } else {
             //$1 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or page number.');
         }
     }
     $destinationArray->items[] = new Zend_Pdf_Element_Name('FitV');
     $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
     return new Zend_Pdf_Destination_FitVertically($destinationArray);
 }
Example #10
0
 protected function createContent(\Zend_Pdf_Page $page)
 {
     $page->setLineWidth(2);
     $page->drawLine(30, 400, 810, 400);
     $em = EntityManager::getInstance();
     $where = "settlement_total_id = " . $this->_settlement->getIdentifier();
     $settlements = $em->findAll("Settlement", $where);
     $lines = count($settlements) + 1;
     $this->setFont($page);
     $page->drawText("Lp.", 40, 383);
     $page->drawText("Nazwisko i imiÄ™ klienta", 90, 383, "UTF-8");
     $page->drawText("Partner", 270, 383);
     $page->drawText("Produkt", 390, 383);
     $page->drawText("Transza", 520, 383);
     $page->drawText("Kwota", 625, 383);
     $page->drawText("Forma wynagrodzenia", 685, 383);
     $lineHeight = 25;
     for ($i = 0; $i <= $lines; $i++) {
         $page->drawLine(30, 400 - $i * $lineHeight, 810, 400 - $i * $lineHeight);
         if ($i > 0 && $i < $lines) {
             $settlement = $settlements[$i - 1];
             $page->drawText($i, 45, 383 - $i * $lineHeight);
             $customer = $settlement->application->customer->lastname . ' ' . $settlement->application->customer->firstname;
             $page->drawText($customer, 80, 383 - $i * $lineHeight, "UTF-8");
             $page->drawText($settlement->application->partner->name, 240, 383 - $i * $lineHeight, "UTF-8");
             $page->drawText($settlement->application->product->name, 360, 383 - $i * $lineHeight, "UTF-8");
             $page->drawText($settlement->parts, 480, 383 - $i * $lineHeight, 'UTF-8');
             $page->drawText($settlement->amount, 630, 383 - $i * $lineHeight);
             $page->drawText($settlement->application->settlementType->name, 725, 383 - $i * $lineHeight);
         }
     }
     $bottomY = 383 - $i * $lineHeight + $lineHeight;
     $page->drawLine(30, 400, 30, 400 - $lines * $lineHeight);
     $page->drawLine(70, 400, 70, 400 - $lines * $lineHeight);
     $page->drawLine(230, 400, 230, 400 - $lines * $lineHeight);
     $page->drawLine(350, 400, 350, 400 - $lines * $lineHeight);
     $page->drawLine(470, 400, 470, 400 - $lines * $lineHeight);
     $page->drawLine(610, 400, 610, 400 - ($lines + 1) * $lineHeight);
     $page->drawLine(675, 400, 675, 400 - ($lines + 1) * $lineHeight);
     $page->drawLine(810, 400, 810, 400 - $lines * $lineHeight);
     $page->drawLine(470, 400 - $lines * $lineHeight, 470, 400 - ($lines + 1) * $lineHeight);
     $page->drawLine(470, 400 - ($lines + 1) * $lineHeight, 675, 400 - ($lines + 1) * $lineHeight);
     $this->setFont($page);
     $page->drawText("Razem", 520, 383 - $lines * $lineHeight);
     $page->drawText($this->_settlement->total, 630, 383 - $lines * $lineHeight);
 }
Example #11
0
 /**
  * Create destination object
  *
  * @param Zend_Pdf_Page|integer $page  Page object or page number
  * @param float $left    Left edge of displayed page
  * @param float $bottom  Bottom edge of displayed page
  * @param float $right   Right edge of displayed page
  * @param float $top     Top edge of displayed page
  * @return Zend_Pdf_Destination_FitRectangle
  * @throws Zend_Pdf_Exception
  */
 public static function create($page, $left, $bottom, $right, $top)
 {
     $destinationArray = new Zend_Pdf_Element_Array();
     if ($page instanceof Zend_Pdf_Page) {
         $destinationArray->items[] = $page->getPageDictionary();
     } elseif (is_integer($page)) {
         $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
     } else {
         require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
     }
     $destinationArray->items[] = new Zend_Pdf_Element_Name('FitR');
     $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
     $destinationArray->items[] = new Zend_Pdf_Element_Numeric($bottom);
     $destinationArray->items[] = new Zend_Pdf_Element_Numeric($right);
     $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
     return new Zend_Pdf_Destination_FitRectangle($destinationArray);
 }
Example #12
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');
         }
     }
 }
Example #13
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');
 }
Example #15
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);
 }
Example #16
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;
 }
Example #17
0
 /**
  * Set font as italic
  *
  * @param  \Zend_Pdf_Page $object
  * @param  int $size
  * @return \Zend_Pdf_Resource_Font
  */
 protected function _setFontItalic($object, $size = 7)
 {
     $font = \Zend_Pdf_Font::fontWithPath($this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_It-2.8.2.ttf'));
     $object->setFont($font, $size);
     return $font;
 }
 /**
  * Create Zend_Pdf_Page instance with image from $imageString. Supports JPEG, PNG, GIF, WBMP, and GD2 formats.
  *
  * @param string $imageString
  * @return Zend_Pdf_Page|bool
  */
 public function createPdfPageFromImageString($imageString)
 {
     $image = imagecreatefromstring($imageString);
     if (!$image) {
         return false;
     }
     $xSize = imagesx($image);
     $ySize = imagesy($image);
     $page = new Zend_Pdf_Page($xSize, $ySize);
     imageinterlace($image, 0);
     $tmpFileName = sys_get_temp_dir() . DS . 'shipping_labels_' . uniqid(mt_rand()) . time() . '.png';
     imagepng($image, $tmpFileName);
     $pdfImage = Zend_Pdf_Image::imageWithPath($tmpFileName);
     $page->drawImage($pdfImage, 0, 0, $xSize, $ySize);
     unlink($tmpFileName);
     return $page;
 }
Example #19
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');
 }
 /**
  * Create \Zend_Pdf_Page instance with image from $imageString. Supports JPEG, PNG, GIF, WBMP, and GD2 formats.
  *
  * @param string $imageString
  * @return \Zend_Pdf_Page|false
  */
 public function createPdfPageFromImageString($imageString)
 {
     /** @var \Magento\Framework\Filesystem\Directory\Write $directory */
     $directory = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
     $directory->create();
     $image = @imagecreatefromstring($imageString);
     if (!$image) {
         return false;
     }
     $xSize = imagesx($image);
     $ySize = imagesy($image);
     $page = new \Zend_Pdf_Page($xSize, $ySize);
     imageinterlace($image, 0);
     $tmpFileName = $directory->getAbsolutePath('shipping_labels_' . uniqid(\Magento\Framework\Math\Random::getRandomNumber()) . time() . '.png');
     imagepng($image, $tmpFileName);
     $pdfImage = \Zend_Pdf_Image::imageWithPath($tmpFileName);
     $page->drawImage($pdfImage, 0, 0, $xSize, $ySize);
     $directory->delete($directory->getRelativePath($tmpFileName));
     return $page;
 }
Example #21
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);
     // Add new page generated by Zend_Pdf_Page object (page is attached to the document)
     $pdf->pages[] = $page3 = $pdf->newPage('A4');
     // 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, 500, 350);
     // Draw rounded rectangle
     $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.9))->setLineColor(new Zend_Pdf_Color_GrayScale(0.5))->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID)->drawRoundedRectangle(425, 350, 475, 400, 20);
     // 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)->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0))->drawCircle(200, 375, 25, M_PI / 6, 2 * M_PI / 3)->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0))->drawCircle(200, 375, 25, -M_PI / 6, M_PI / 6);
     // Draw ellipse
     $page2->setFillColor(new Zend_Pdf_Color_Html('Red'))->drawEllipse(250, 400, 400, 350)->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0))->drawEllipse(250, 400, 400, 350, M_PI / 6, 2 * M_PI / 3)->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0))->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)->drawLine(60, 375, 500, 375);
     // -----------------------------------------------------------------------------------
     $page3->translate(200, 10)->rotate(10, 10, M_PI_2 / 9)->scale(0.7, 1.2)->skew(60, 350, M_PI_2 / 9, -M_PI_2 / 9);
     // Use font object for another page
     $page3->setFont($font, 24)->drawText('Helvetica 24 text string', 60, 500);
     // Use another font
     $page3->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32)->drawText('Times-Roman 32 text string', 60, 450);
     // Draw rectangle
     $page3->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, 500, 350);
     // Draw rounded rectangle
     $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.9))->setLineColor(new Zend_Pdf_Color_GrayScale(0.5))->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID)->drawRoundedRectangle(425, 350, 475, 400, 20);
     // Draw circle
     $page3->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID)->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0))->drawCircle(85, 375, 25);
     // Draw sectors
     $page3->drawCircle(200, 375, 25, 2 * M_PI / 3, -M_PI / 6)->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0))->drawCircle(200, 375, 25, M_PI / 6, 2 * M_PI / 3)->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0))->drawCircle(200, 375, 25, -M_PI / 6, M_PI / 6);
     // Draw ellipse
     $page3->setFillColor(new Zend_Pdf_Color_Html('Red'))->drawEllipse(250, 400, 400, 350)->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0))->drawEllipse(250, 400, 400, 350, M_PI / 6, 2 * M_PI / 3)->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0))->drawEllipse(250, 400, 400, 350, -M_PI / 6, M_PI / 6);
     // Draw and fill polygon
     $page3->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);
     }
     $page3->drawPolygon($x, $y, Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, Zend_Pdf_Page::FILL_METHOD_EVEN_ODD);
     // Draw line
     $page3->setLineWidth(0.5)->drawLine(60, 375, 500, 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');
 }
Example #22
0
 /**
  * Prepares the text so that it fits to the given page's width.
  *
  * @param  string                 $text     the text which should be prepared
  * @param  Zend_Pdf_Page          $page     the page on which the text will be rendered
  * @param  Zend_Pdf_Resource_Font $font     the font with which the text will be rendered
  * @param  int                    $fontSize the font size with which the text will be rendered
  * @param  int                    $width    [optional] the width for the given text, defaults to the page width
  *
  * @return array the given text in an array where each item represents a new line
  */
 public function _prepareText($text, $page, $font, $fontSize, $width = null)
 {
     if (empty($text)) {
         return array();
     }
     $lines = '';
     $currentLine = '';
     // calculate the page's width with respect to the margins
     if (empty($width)) {
         $width = $page->getWidth() - $this->margin['left'] - ($page->getWidth() - $this->margin['right']);
     }
     $textChunks = explode(' ', $text);
     foreach ($textChunks as $textChunk) {
         if ($this->widthForStringUsingFontSize($currentLine . ' ' . $textChunk, $font, $fontSize) < $width) {
             // do not add whitespace on first line
             if (!empty($currentLine)) {
                 $currentLine .= ' ';
             }
             $currentLine .= $textChunk;
         } else {
             // text is too broad, so add new line character
             $lines .= $currentLine . "\n";
             $currentLine = $textChunk;
         }
     }
     // append the last line
     $lines .= $currentLine;
     return explode("\n", $lines);
 }
Example #23
0
    $page->rotate(0, 0, M_PI_2/3);

    $page->saveGS();
    $page->clipCircle(550, -10, 50);
    $page->drawImage($stampImage, 500, -60, 600, 40);
    $page->restoreGS();

    $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[] = ($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);
Example #24
0
 /**
  *
  * @param Zend_Pdf_Page $page 
  * @return void Process drawImage on PDF page
  */
 protected function drawWaterMask(&$page)
 {
     if (Mage::getStoreConfig('advancedinvoiceprinting_options/general/enable') == 0) {
         return;
     }
     $pageWidth = $page->getWidth();
     $pageHeight = $page->getHeight();
     $image = $this->getImage();
     if (is_file($image)) {
         /* @var $image Zend_Pdf_Resource_Image */
         $image = Zend_Pdf_Image::imageWithPath($image);
         $imgWidth = $image->getPixelWidth();
         $imgHeight = $image->getPixelHeight();
         $percent = Mage::getStoreConfig('advancedinvoiceprinting_options/general/images_size');
         $imgWidth = $imgWidth * $percent / 100;
         $imgHeight = $imgHeight * $percent / 100;
         $x = ($pageWidth - $imgWidth) / 2;
         $y = ($pageHeight - $imgHeight) / 2;
         if (is_numeric(Mage::getStoreConfig('advancedinvoiceprinting_options/general/offset_x'))) {
             $x = $x + (int) Mage::getStoreConfig('advancedinvoiceprinting_options/general/offset_x');
         }
         if (is_numeric(Mage::getStoreConfig('advancedinvoiceprinting_options/general/offset_y'))) {
             $y = $y - (int) Mage::getStoreConfig('advancedinvoiceprinting_options/general/offset_y');
         }
         $page->drawImage($image, $x, $y, $x + $imgWidth, $y + $imgHeight);
     }
 }
Example #25
0
 /**
  * Set font as italic
  *
  * @param  Zend_Pdf_Page $object
  * @param  int $size
  * @return Zend_Pdf_Resource_Font
  */
 protected function _setFontItalic($object, $size = 7)
 {
     $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_It-2.8.2.ttf');
     $object->setFont($font, $size);
     return $font;
 }
Example #26
0
 function pdfdisplayAction()
 {
     $app = $this->view->baseUrl();
     $word = explode('/', $app);
     $projname = $word[1];
     $pdf = new Zend_Pdf();
     $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
     $pdf->pages[] = $page;
     // Image
     $image_name = "/var/www/" . $projname . "/public/images/logo.jpg";
     $image = Zend_Pdf_Image::imageWithPath($image_name);
     //$page->drawImage($image, 25, 770, 570, 820);
     $page->drawImage($image, 30, 770, 130, 820);
     $page->setLineWidth(1)->drawLine(25, 25, 570, 25);
     //bottom horizontal
     // 		$page->setLineWidth(1)->drawLine(25, 640, 25, 500);
     $page->setLineWidth(1)->drawLine(25, 25, 25, 820);
     //left vertical
     $page->setLineWidth(1)->drawLine(570, 25, 570, 820);
     //right vertical
     $page->setLineWidth(1)->drawLine(570, 820, 25, 820);
     //top horizonta
     // define font resource
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     // Image
     $image_name = "/var/www/" . $projname . "/public/images/logo.jpg";
     $image = Zend_Pdf_Image::imageWithPath($image_name);
     $x1 = 72;
     $x2 = 410;
     $y1 = 690;
     $Declaration = new Declaration_Model_Dec();
     $code = $this->_request->getParam('groupcode');
     $this->view->result = $this->view->loan->groupDeatils($code);
     $this->view->groupmembers = $this->view->loan->getgroupmembers($code);
     $dateconvert = new App_Model_dateConvertor();
     foreach ($this->view->result as $result) {
         //    // write text to page
         $page->setFont($font, 12)->drawText('Group bye law', 240, 720);
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate local development by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate local development by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate local development by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate   ' . $result['dayname'] . 'The vision of Ourbank is to stimulate ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to    ' . $result['place'] . '  stimulate local development by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimulate  ' . $result['saving_perweek'] . '  pment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimu  ' . $result['rateinterest'] . '  velopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stim  ' . $result['penalty_latecoming'] . '  evelopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stim   ' . $result['penalty_notcoming'] . '  velopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to st   ' . $result['group_created_date'] . '   elopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('The vision of Ourbank is to stimu    ' . $result['name'] . '    elopment by offering small and medium ', $x1, $y1);
         $y1 = $y1 - 15;
         $page->setLineWidth(1)->drawLine(50, $y1, 550, $y1);
         $y1 = $y1 - 15;
         $page->setFont($font, 9)->drawText('Member name', 72, $y1);
         $page->setFont($font, 9)->drawText('UID', 160, $y1);
         $page->setFont($font, 9)->drawText('Father name', 200, $y1);
         $page->setFont($font, 9)->drawText('Nominee', 280, $y1);
         $page->setFont($font, 9)->drawText('Nominee relationship', 350, $y1);
         $page->setFont($font, 9)->drawText('Signature', 460, $y1);
         $y1 = $y1 - 10;
         $page->setLineWidth(1)->drawLine(50, $y1, 550, $y1);
         foreach ($this->view->groupmembers as $member) {
             $y1 = $y1 - 15;
             $page->setFont($font, 9)->drawText('' . $member['membername'] . '', 72, $y1);
             $page->setFont($font, 9)->drawText('' . $member['uid'] . '', 140, $y1);
             $page->setFont($font, 9)->drawText('' . $member['family_id'] . '', 200, $y1);
             $y1 = $y1 - 10;
             $page->setLineWidth(1)->drawLine(50, $y1, 550, $y1);
         }
     }
     $pdf->pages[] = $page;
     $pdfData = $pdf->render();
     $pdfData = $pdf->render();
     $pdf->save('/var/www/' . $projname . '/reports/grouplaw.pdf');
     $path = '/var/www/' . $projname . '/reports/grouplaw.pdf';
     chmod($path, 0777);
     //                 $this->_redirect('/declaration/index');
 }
Example #27
0
    $page->saveGS();
    $page->clipCircle(550, -10, 50);
    if ($stampImage != null) {
        $page->drawImage($stampImage, 500, -60, 600, 40);
    }
    $page->restoreGS();

    $page->drawText('Modified by Zend Framework!', 150, 0)
         ->restoreGS();
}

// 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)
      ->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)
Example #28
0
 /**
  * Clone page, extract it and dependent objects from the current document,
  * so it can be used within other docs
  *
  * return Zend_Pdf_Page
  */
 public function clonePage(Zend_Pdf_Page $page)
 {
     return $page->clonePage($this->_factory, $this->_processed);
 }
Example #29
0
 /**
  * Constructor.
  *
  * @param mixed $param1
  * @param mixed $param2
  * @param mixed $param3
  *
  * @throws Zend_Pdf_Exception
  *
  * @return void
  */
 public function __construct($param1, $param2 = NULL, $param3 = NULL)
 {
     parent::__construct($param1, $param2, $param3);
     if ($param1 instanceof Phprojekt_Pdf_Page && $param2 === null && $param3 === null) {
         // Clone additional properties
         $this->setBorder($param1->borderTop, $param1->borderRight, $param1->borderBottom, $param1->borderLeft);
     }
 }
Example #30
0
 /**
  * Insert address to pdf page
  *
  * @param Zend_Pdf_Page $page
  * @param null $store
  */
 protected function insertAddress(&$page, $store = null)
 {
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
     $font = $this->_setFontRegular($page, 10);
     $page->setLineWidth(0);
     $this->y = $this->y ? $this->y : 815;
     $top = 815;
     $collection = Mage::getModel('marketplace/userprofile')->getCollection()->addFieldToFilter('mageuserid', array('eq' => Mage::getSingleton('customer/session')->getCustomerId()));
     foreach ($collection as $row) {
         $address = $row->getOthersInfo();
     }
     foreach (explode("\n", $address) as $value) {
         if ($value !== '') {
             $value = preg_replace('/<br[^>]*>/i', "\n", $value);
             foreach (Mage::helper('core/string')->str_split($value, 45, true, true) as $_value) {
                 $page->drawText(trim(strip_tags($_value)), $this->getAlignRight($_value, 130, 440, $font, 10), $top, 'UTF-8');
                 $top -= 10;
             }
         }
     }
     $this->y = $this->y > $top ? $top : $this->y;
 }