Exemple #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;
 }
 protected function _addPaidIcon(&$page)
 {
     $image = Mage::helper('emjainteractive_purchaseordermanagement')->getIconFullPath();
     if (is_file($image)) {
         $image = Zend_Pdf_Image::imageWithPath($image);
         $page->drawImage($image, 220, 600, 280, 650);
     }
     return $this;
 }
Exemple #3
0
 public function process($page, &$column, &$top, $lineSpacing, $pdf)
 {
     $info = $column['info'];
     if (isset($info['image']) && strlen($info['image']) > 0) {
         $image = Zend_Pdf_Image::imageWithPath($info['image']);
         $page->drawImage($image, $column['feed'], $pdf->y - 50, $column['feed'] + 50, $pdf->y);
         $top += 60;
     }
 }
 /**
  * Object constructor
  *
  * @param string $imageFileName
  * @throws Zend_Pdf_Exception
  */
 public function __construct($imageFileName)
 {
     if (!function_exists('gd_info')) {
         throw new Zend_Pdf_Exception('Image extension is not installed.');
     }
     $gd_options = gd_info();
     if (!$gd_options['JPG Support']) {
         throw new Zend_Pdf_Exception('JPG support is not configured properly.');
     }
     if (($imageInfo = getimagesize($imageFileName)) === false) {
         throw new Zend_Pdf_Exception('Corrupted image or image doesn\'t exist.');
     }
     if ($imageInfo[2] != IMAGETYPE_JPEG && $imageInfo[2] != IMAGETYPE_JPEG2000) {
         throw new Zend_Pdf_Exception('ImageType is not JPG');
     }
     parent::__construct();
     switch ($imageInfo['channels']) {
         case 3:
             $colorSpace = 'DeviceRGB';
             break;
         case 4:
             $colorSpace = 'DeviceCMYK';
             break;
         default:
             $colorSpace = 'DeviceGray';
             break;
     }
     $imageDictionary = $this->_resource->dictionary;
     $imageDictionary->Width = new Zend_Pdf_Element_Numeric($imageInfo[0]);
     $imageDictionary->Height = new Zend_Pdf_Element_Numeric($imageInfo[1]);
     $imageDictionary->ColorSpace = new Zend_Pdf_Element_Name($colorSpace);
     $imageDictionary->BitsPerComponent = new Zend_Pdf_Element_Numeric($imageInfo['bits']);
     if ($imageInfo[2] == IMAGETYPE_JPEG) {
         $imageDictionary->Filter = new Zend_Pdf_Element_Name('DCTDecode');
     } else {
         if ($imageInfo[2] == IMAGETYPE_JPEG2000) {
             $imageDictionary->Filter = new Zend_Pdf_Element_Name('JPXDecode');
         }
     }
     if (($imageFile = @fopen($imageFileName, 'rb')) === false) {
         throw new Zend_Pdf_Exception("Can not open '{$imageFileName}' file for reading.");
     }
     $byteCount = filesize($imageFileName);
     $this->_resource->value = '';
     while ($byteCount > 0 && ($nextBlock = fread($imageFile, $byteCount)) != false) {
         $this->_resource->value .= $nextBlock;
         $byteCount -= strlen($nextBlock);
     }
     fclose($imageFile);
     $this->_resource->skipFilters();
     $this->_width = $imageInfo[0];
     $this->_height = $imageInfo[1];
     $this->_imageProperties = array();
     $this->_imageProperties['bitDepth'] = $imageInfo['bits'];
     $this->_imageProperties['jpegImageType'] = $imageInfo[2];
     $this->_imageProperties['jpegColorType'] = $imageInfo['channels'];
 }
Exemple #5
0
 /**
  * Place vendor logo into page
  * @param $page
  */
 public function drawLogo($page)
 {
     $vendorId = Mage::getSingleton('udropship/session')->getId();
     $vendor = Mage::helper('udropship')->getVendor($vendorId);
     $img = Mage::getBaseDir('media') . DS . $vendor->getLogo();
     if (is_file($img)) {
         $image = Zend_Pdf_Image::imageWithPath($img);
         $page->drawImage($image, 25, 805, 125, 830);
     }
 }
 /**
  * Insert le logo
  *
  * @param unknown_type $page
  */
 protected function insertLogo(&$page, $StoreId = null)
 {
     $image = Mage::getStoreConfig('sales/identity/logo', $StoreId);
     if ($image) {
         $image = Mage::getStoreConfig('system/filesystem/media') . '/sales/store/logo/' . $image;
         if (is_file($image)) {
             $image = Zend_Pdf_Image::imageWithPath($image);
             $page->drawImage($image, 25, 785, 25 + $this->_LOGO_LARGEUR, 785 + $this->_LOGO_HAUTEUR);
         }
     }
     //return $page;
 }
 protected function insertLogo(&$page, $store = null)
 {
     $image = Mage::getStoreConfig('sales/identity/logo', $store);
     if ($image) {
         $image = Mage::getBaseDir('media') . '/sales/store/logo/' . $image;
         if (is_file($image)) {
             $image = Zend_Pdf_Image::imageWithPath($image);
             $page->drawImage($image, 25, 800, 125, 825);
         }
     }
     //return $page;
 }
Exemple #8
0
 /**
  * create a order pdf modelled on the invoice content
  *
  * @param array $orders
  *
  * @return Zend_Pdf
  */
 protected function insertImage($imageLocation, $x1, $y1, $x2, $y2, $width, $height, &$page)
 {
     try {
         $width = (int) $width;
         $height = (int) $height;
         //Get product image and resize it
         $image = Zend_Pdf_Image::imageWithPath($imageLocation);
         //Draw image to PDF
         $page->drawImage($image, $x1, $y1, $x2, $y2);
     } catch (Exception $e) {
         return false;
     }
 }
Exemple #9
0
 protected function insertLogo(&$page, $store = null)
 {
     $image = Mage::getStoreConfig('sales/identity/logo', $store);
     if ($image) {
         $this->y = 780;
         $x = $this->_leftRectPad;
         $y = $this->y;
         $image = Mage::getBaseDir('media') . '/sales/store/logo/' . $image;
         if (is_file($image)) {
             $image = Zend_Pdf_Image::imageWithPath($image);
             $page->drawImage($image, $x, $y, $x + 200, $y + 50);
         }
     }
     //return $page;
 }
Exemple #10
0
 /**
  * Object constructor
  *
  * @param string $imageFileName
  * @throws Zend_Pdf_Exception
  */
 public function __construct($imageFileName)
 {
     if (($imageInfo = getimagesize($imageFileName)) === false) {
         throw new Zend_Pdf_Exception('Corrupted image or image doesn\'t exist.');
     }
     if ($imageInfo[2] != IMAGETYPE_TIFF_II && $imageInfo[2] != IMAGETYPE_TIFF_MM) {
         throw new Zend_Pdf_Exception('ImageType is not TIFF');
     }
     parent::__construct();
     /* This needs to be fixed
         switch ($imageInfo['channels']) {
             case 3:
                 $colorSpace = 'DeviceRGB';
                 break;
             case 4:
                 $colorSpace = 'DeviceCMYK';
                 break;
             default:
                 $colorSpace = 'DeviceGray';
                 break;
         }
        */
     /*
     This is a temporary hack - this needs to be read from the tiff file format.
     IMAGICK pecl extension contains imagick_getcolorspace but introducing another
     extension dependency is probably bad.
     */
     $colorSpace = 'DeviceRGB';
     $imageDictionary = $this->_resource->dictionary;
     $imageDictionary->Width = new Zend_Pdf_Element_Numeric($imageInfo[0]);
     $imageDictionary->Height = new Zend_Pdf_Element_Numeric($imageInfo[1]);
     $imageDictionary->ColorSpace = new Zend_Pdf_Element_Name($colorSpace);
     //      $imageDictionary->BitsPerComponent = new Zend_Pdf_Element_Numeric($imageInfo['bits']);
     //This is also a temporary hack - Corresponds imagick_getimagedepth
     $imageDictionary->BitsPerComponent = new Zend_Pdf_Element_Numeric(8);
     if (($imageFile = @fopen($imageFileName, 'rb')) === false) {
         throw new Zend_Pdf_Exception("Can not open '{$imageFileName}' file for reading.");
     }
     $byteCount = filesize($imageFileName);
     $this->_resource->value = '';
     while ($byteCount > 0 && ($nextBlock = fread($imageFile, $byteCount)) != false) {
         $this->_resource->value .= $nextBlock;
         $byteCount -= strlen($nextBlock);
     }
     fclose($imageFile);
     $this->_resource->skipFilters();
 }
Exemple #11
0
 public function setHeader()
 {
     $this->_page->saveGS();
     $this->_page->setFont($this->_normalFont, 10);
     $this->_page->drawText('ỦY BAN NHÂN DÂN', $this->_leftMargin + 52, $this->_pageHeight - 22, 'UTF-8')->drawText('THÀNH PHÔ HỒ CHÍ MINH', $this->_leftMargin + 40, $this->_pageHeight - 34, 'UTF-8');
     $this->_page->setFont($this->_boldFont, 11);
     $this->_page->drawText('TRƯỜNG ĐẠI HỌC SÀI GÒN', $this->_leftMargin + 30, $this->_pageHeight - 46, 'UTF-8');
     $this->_page->setLineWidth(0.1);
     $this->_page->drawLine($this->_leftMargin + 60, $this->_pageHeight - 50, $this->_pageWidth - 437, $this->_pageHeight - 50);
     $this->_page->setFont($this->_boldFont, 11);
     $this->_page->drawText('CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM', $this->_leftMargin + 300, $this->_pageHeight - 22, 'UTF-8');
     $this->_page->setFont($this->_normalFont, 11);
     $this->_page->drawText('Độc lập - Tự do - Hạnh phúc', $this->_leftMargin + 340, $this->_pageHeight - 34, 'UTF-8');
     //--------------drawImage(image, left, bottom, right, top)
     $imagePath = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/templates/admin/images/symbol.png');
     $this->_page->drawImage($imagePath, $this->_leftMargin + 380, $this->_pageHeight - 49, $this->_leftMargin + 415, $this->_pageHeight - 39);
     $this->_page->restoreGS();
 }
Exemple #12
0
 /**
  * Generate a QR code for the given data.
  *
  * @return Zend_Pdf_Image
  */
 public function generate($data)
 {
     $temp = tempnam($this->_tempDir, self::TEMP_FILE_PREFIX);
     // Zend_Pdf_Image dies if lacking the correct file extension.
     $tempPng = $temp . ".png";
     rename($temp, $tempPng);
     $temp = $tempPng;
     $url = $this->_qrCodeUri($data);
     $client = new Omeka_Http_Client($url);
     $client->setMaxRetries(10);
     $response = $client->request('GET');
     if ($response->isSuccessful()) {
         file_put_contents($temp, $response->getBody());
         $image = Zend_Pdf_Image::imageWithPath($temp);
         unlink($temp);
         return $image;
     } else {
         throw new Zend_Http_Client_Exception("Could not retrieve QR chart from Google.");
     }
 }
Exemple #13
0
 protected function insertLogo17(&$page, $store = null)
 {
     $this->y = $this->y ? $this->y : 800;
     $image = Mage::getStoreConfig('sales/identity/logo', $store);
     if ($image) {
         $image = Mage::getBaseDir('media') . '/sales/store/logo/' . $image;
         if (is_file($image)) {
             $image = Zend_Pdf_Image::imageWithPath($image);
             $top = 830;
             //top border of the page
             $widthLimit = 270;
             //half of the page width
             $heightLimit = 270;
             //assuming the image is not a "skyscraper"
             $width = $image->getPixelWidth();
             $height = $image->getPixelHeight();
             //preserving aspect ratio (proportions)
             $ratio = $width / $height;
             if ($ratio > 1 && $width > $widthLimit) {
                 $width = $widthLimit;
                 $height = $width / $ratio;
             } elseif ($ratio < 1 && $height > $heightLimit) {
                 $height = $heightLimit;
                 $width = $height * $ratio;
             } elseif ($ratio == 1 && $height > $heightLimit) {
                 $height = $heightLimit;
                 $width = $widthLimit;
             }
             $y1 = $top - $height;
             $y2 = $top;
             $x1 = 25;
             $x2 = $x1 + $width;
             //coordinates after transformation are rounded by Zend
             $page->drawImage($image, $x1, $y1, $x2, $y2);
             $this->y = $y1 - 10;
         }
     }
 }
 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);
 }
Exemple #16
0
 public function getPdf($couponIds)
 {
     // $this->_beforeGetPdf();
     if ($couponIds) {
         $pdf = new Zend_Pdf();
         $this->_setPdf($pdf);
         $style = new Zend_Pdf_Style();
         $this->_setFontBold($style, 10);
         $couponIds = array_chunk($couponIds, 8);
         foreach ($couponIds as $coupons) {
             $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
             $pdf->pages[] = $page;
             $this->y = 790;
             $i = 0;
             foreach ($coupons as $couponId) {
                 $couponOffer = $this->_getCouponById($couponId);
                 if ($couponOffer->getId()) {
                     $i++;
                     if ($i % 2 == 0) {
                         /* Add Border */
                         $page->setFillColor(new Zend_Pdf_Color_Rgb(255, 255, 255));
                         $page->setLineColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getPdfStyleColor()));
                         $page->setLineWidth(0.5);
                         $page->setLineDashingPattern(array(3, 2, 3, 4), 1.6);
                         //                            $page->drawRectangle(310, $this->y, 560, $this->y - 170);
                         /* Insert Background image */
                         $store = Mage::app()->getStore($couponOffer->getStoreId());
                         $background_image = Mage::helper('rewardpointsreferfriends')->getBackgroundImg($store->getId());
                         if ($background_image) {
                             $background_image = Mage::getBaseDir('media') . DS . 'rewardpointsreferfriends/pdf/background/' . $background_image;
                             if (is_file($background_image)) {
                                 $background_image = Zend_Pdf_Image::imageWithPath($background_image);
                                 $page->drawImage($background_image, 310, $this->y - 170, 560, $this->y);
                             }
                         } else {
                             $background_image = Mage::getBaseDir('media') . DS . 'rewardpointsreferfriends/pdf/background/default/background.jpg';
                             if (is_file($background_image)) {
                                 $background_image = Zend_Pdf_Image::imageWithPath($background_image);
                                 $page->drawImage($background_image, 310, $this->y - 170, 560, $this->y);
                             }
                         }
                         /* Insert Image Logo */
                         $store = Mage::app()->getStore($couponOffer->getStoreId());
                         $image = Mage::getStoreConfig('rewardpoints/referfriendplugin/logo', $store->getId());
                         if ($image) {
                             $image = Mage::getBaseDir('media') . DS . 'rewardpointsreferfriends/pdf/logo/' . $image;
                             if (is_file($image)) {
                                 $image = Zend_Pdf_Image::imageWithPath($image);
                                 $page->drawImage($image, 320, $this->y - 79, 395, $this->y - 59);
                             }
                         } else {
                             $image = Mage::getBaseDir('media') . DS . 'rewardpointsreferfriends/pdf/logo/default/logo_print.png';
                             if (is_file($image)) {
                                 $image = Zend_Pdf_Image::imageWithPath($image);
                                 $page->drawImage($image, 320, $this->y - 79, 395, $this->y - 59);
                             }
                         }
                         //                        Insert discount
                         $page->setFillColor(new Zend_Pdf_Color_Html('#FF0000'));
                         $font = $this->_setFontBold($page, 40);
                         $special_offer = $this->getOfferDiscount();
                         $default_offer = $this->getDefaultDiscount();
                         if ($special_offer) {
                             $page->drawText($special_offer, 470, $this->y - 70, 'UTF-8');
                         } else {
                             if ($default_offer) {
                                 $page->drawText($default_offer, 470, $this->y - 70, 'UTF-8');
                             }
                         }
                         //                        Insert coupon id
                         //                            $page->setFillColor(new Zend_Pdf_Color_Html('#000000'));
                         //                            $this->_setFontBold($page, 10);
                         //                            $page->drawText(Mage::helper('rewardpointsreferfriends')->__('No: ' . $couponOffer->getId()), 340, $this->y - 85, 'UTF-8');
                         /* Insert caption */
                         $page->setFillColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getPdfStyleColor()));
                         $this->_setFontBold($page, 14);
                         $page->drawText(Mage::helper('rewardpointsreferfriends')->getCaptionCoupon(), 470, $this->y - 30, 'UTF-8');
                         /* Coupon code */
                         $page->setFillColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getBackgroundCoupon()));
                         $page->setLineColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getBackgroundCoupon()));
                         $page->setLineDashingPattern();
                         $page->setLineWidth(0);
                         $page->drawRectangle(320, $this->y - 90, 550, $this->y - 115);
                         $page->setFillColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getPdfCouponColor()));
                         $font = $this->_setFontBold($page, 14);
                         $page->drawText($couponOffer->getCoupon(), 770 / 2 - $this->getTextWidth($couponOffer->getCoupon(), $font, 14) / 2, $this->y - 108, 'UTF-8');
                         //                    /* NOTE */
                         //                        $page->setFillColor(new Zend_Pdf_Color_Html('#000000'));
                         //                        $this->_setFontBold($page, 8);
                         //                        $page->drawText(Mage::helper('rewardpointsreferfriends')->__('Notes: '), 85, $this->y - 175, 'UTF-8');
                         $page->setFillColor(new Zend_Pdf_Color_Html('#000000'));
                         $font = $this->_setFontItalic($page, 8);
                         $notes = $this->getPrintNotes($couponOffer, $font, 230);
                         $drawY = $this->y - 130;
                         foreach ($notes as $note) {
                             if ($note != '') {
                                 $this->_printHyperLink($page, $note, 320, $drawY);
                                 //                                    $page->drawText($note, 70, $drawY, 'UTF-8');
                                 $drawY -= 9;
                             }
                         }
                         $temp = $this->y - 180;
                         $this->y = $temp;
                     } else {
                         /* Add Border */
                         $page->setFillColor(new Zend_Pdf_Color_Rgb(255, 255, 255));
                         $page->setLineColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getPdfStyleColor()));
                         $page->setLineWidth(0.5);
                         $page->setLineDashingPattern(array(3, 2, 3, 4), 1.6);
                         //                            $page->drawRectangle(50, $this->y, 300, $this->y - 170);
                         /* Insert Background image */
                         $store = Mage::app()->getStore($couponOffer->getStoreId());
                         $background_image = Mage::helper('rewardpointsreferfriends')->getBackgroundImg($store->getId());
                         if ($background_image) {
                             $background_image = Mage::getBaseDir('media') . DS . 'rewardpointsreferfriends/pdf/background/' . $background_image;
                             if (is_file($background_image)) {
                                 $background_image = Zend_Pdf_Image::imageWithPath($background_image);
                                 $page->drawImage($background_image, 50, $this->y - 170, 300, $this->y);
                             }
                         } else {
                             $background_image = Mage::getBaseDir('media') . DS . 'rewardpointsreferfriends/pdf/background/default/background.jpg';
                             if (is_file($background_image)) {
                                 $background_image = Zend_Pdf_Image::imageWithPath($background_image);
                                 $page->drawImage($background_image, 50, $this->y - 170, 300, $this->y);
                             }
                         }
                         /* Insert Image Logo */
                         $store = Mage::app()->getStore($couponOffer->getStoreId());
                         $image = Mage::getStoreConfig('rewardpoints/referfriendplugin/logo', $store->getId());
                         if ($image) {
                             $image = Mage::getBaseDir('media') . DS . 'rewardpointsreferfriends/pdf/logo/' . $image;
                             if (is_file($image)) {
                                 $image = Zend_Pdf_Image::imageWithPath($image);
                                 $page->drawImage($image, 60, $this->y - 79, 135, $this->y - 59);
                             }
                         } else {
                             $image = Mage::getBaseDir('media') . DS . 'rewardpointsreferfriends/pdf/logo/default/logo_print.png';
                             if (is_file($image)) {
                                 $image = Zend_Pdf_Image::imageWithPath($image);
                                 $page->drawImage($image, 60, $this->y - 79, 135, $this->y - 59);
                             }
                         }
                         //                        Insert discount
                         $page->setFillColor(new Zend_Pdf_Color_Html('#FF0000'));
                         $font = $this->_setFontBold($page, 40);
                         $special_offer = $this->getOfferDiscount();
                         $default_offer = $this->getDefaultDiscount();
                         if ($special_offer) {
                             $page->drawText($special_offer, 210, $this->y - 70, 'UTF-8');
                         } else {
                             if ($default_offer) {
                                 $page->drawText($default_offer, 210, $this->y - 70, 'UTF-8');
                             }
                         }
                         //                        Insert coupon id
                         //                            $page->setFillColor(new Zend_Pdf_Color_Html('#000000'));
                         //                            $this->_setFontBold($page, 10);
                         //                            $page->drawText(Mage::helper('rewardpointsreferfriends')->__('No: ' . $couponOffer->getId()), 80, $this->y - 85, 'UTF-8');
                         /* Insert caption */
                         $page->setFillColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getPdfStyleColor()));
                         $this->_setFontBold($page, 14);
                         $page->drawText(Mage::helper('rewardpointsreferfriends')->getCaptionCoupon(), 210, $this->y - 30, 'UTF-8');
                         /* Coupon code */
                         $page->setFillColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getBackgroundCoupon()));
                         $page->setLineColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getBackgroundCoupon()));
                         $page->setLineDashingPattern();
                         $page->setLineWidth(0);
                         $page->drawRectangle(60, $this->y - 90, 290, $this->y - 115);
                         $page->setFillColor(new Zend_Pdf_Color_Html(Mage::helper('rewardpointsreferfriends')->getPdfCouponColor()));
                         $font = $this->_setFontBold($page, 14);
                         $page->drawText($couponOffer->getCoupon(), 250 / 2 - $this->getTextWidth($couponOffer->getCoupon(), $font, 14) / 2, $this->y - 108, 'UTF-8');
                         //                    /* NOTE */
                         //                        $page->setFillColor(new Zend_Pdf_Color_Html('#000000'));
                         //                        $this->_setFontBold($page, 8);
                         //                        $page->drawText(Mage::helper('rewardpointsreferfriends')->__('Notes: '), 85, $this->y - 175, 'UTF-8');
                         $page->setFillColor(new Zend_Pdf_Color_Html('#000000'));
                         $font = $this->_setFontItalic($page, 8);
                         $notes = $this->getPrintNotes($couponOffer, $font, 230);
                         $drawY = $this->y - 130;
                         foreach ($notes as $note) {
                             if ($note != '') {
                                 $this->_printHyperLink($page, $note, 60, $drawY);
                                 //                                    $page->drawText($note, 70, $drawY, 'UTF-8');
                                 $drawY -= 9;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $pdf;
 }
 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);
 }
Exemple #18
0
//------------------------------------------------------------------------------------
// Reverse page order
$pdf->pages = array_reverse($pdf->pages);

// Create new Style
$style = new Zend_Pdf_Style();
$style->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0.9));
$style->setLineColor(new Zend_Pdf_Color_GrayScale(0.2));
$style->setLineWidth(3);
$style->setLineDashingPattern(array(3, 2, 3, 4), 1.6);
$style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32);

try {
    // Create new image object
    require_once 'Zend/Pdf/Image.php';
    $stampImage = Zend_Pdf_Image::imageWithPath(__DIR__ . '/stamp.jpg');
} catch (Zend_Pdf_Exception $e) {
    // Example of operating with image loading exceptions.
    if ($e->getMessage() != 'Image extension is not installed.' &&
        $e->getMessage() != 'JPG support is not configured properly.') {
        throw $e;
    }
    $stampImage = null;
}

// Mark page as modified
foreach ($pdf->pages as $page){
    $page->saveGS()
         ->setAlpha(0.25)
         ->setStyle($style)
         ->rotate(0, 0, M_PI_2/3);
 public function testImageDrawing()
 {
     $pdf = new Zend_Pdf();
     // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
     $pdf->pages[] = $page = $pdf->newPage('A4');
     $stampImagePNG = Zend_Pdf_Image::imageWithPath(dirname(__FILE__) . '/_files/stamp.png');
     $this->assertTrue($stampImagePNG instanceof Zend_Pdf_Resource_Image);
     $page->saveGS()->clipCircle(250, 500, 50)->drawImage($stampImagePNG, 200, 450, 300, 550)->restoreGS();
     $stampImageTIFF = Zend_Pdf_Image::imageWithPath(dirname(__FILE__) . '/_files/stamp.tif');
     $this->assertTrue($stampImageTIFF instanceof Zend_Pdf_Resource_Image);
     $page->saveGS()->clipCircle(325, 500, 50)->drawImage($stampImagePNG, 275, 450, 375, 550)->restoreGS();
     $jpegSupported = false;
     if (function_exists('gd_info')) {
         $info = gd_info();
         if (isset($info['JPG Support'])) {
             $jpegSupported = $info['JPG Support'];
         } elseif (isset($info['JPEG Support'])) {
             $jpegSupported = $info['JPEG Support'];
         }
     }
     if ($jpegSupported) {
         $stampImageJPG = Zend_Pdf_Image::imageWithPath(dirname(__FILE__) . '/_files/stamp.jpg');
         $this->assertTrue($stampImageJPG instanceof Zend_Pdf_Resource_Image);
         $page->saveGS()->clipCircle(287.5, 440, 50)->drawImage($stampImageJPG, 237.5, 390, 337.5, 490)->restoreGS();
         $page->saveGS()->clipCircle(250, 500, 50)->clipCircle(287.5, 440, 50)->drawImage($stampImagePNG, 200, 450, 300, 550)->restoreGS();
     }
     $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');
 }
 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');
 }
Exemple #21
0
 /**
  * Insert logo to pdf page
  *
  * @param \Zend_Pdf_Page &$page
  * @param null $store
  * @return void
  */
 protected function insertLogo(&$page, $store = null)
 {
     $this->y = $this->y ? $this->y : 815;
     $image = $this->_scopeConfig->getValue('sales/identity/logo', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
     if ($image) {
         $imagePath = '/sales/store/logo/' . $image;
         if ($this->_mediaDirectory->isFile($imagePath)) {
             $image = \Zend_Pdf_Image::imageWithPath($this->_mediaDirectory->getAbsolutePath($imagePath));
             $top = 830;
             //top border of the page
             $widthLimit = 270;
             //half of the page width
             $heightLimit = 270;
             //assuming the image is not a "skyscraper"
             $width = $image->getPixelWidth();
             $height = $image->getPixelHeight();
             //preserving aspect ratio (proportions)
             $ratio = $width / $height;
             if ($ratio > 1 && $width > $widthLimit) {
                 $width = $widthLimit;
                 $height = $width / $ratio;
             } elseif ($ratio < 1 && $height > $heightLimit) {
                 $height = $heightLimit;
                 $width = $height * $ratio;
             } elseif ($ratio == 1 && $height > $heightLimit) {
                 $height = $heightLimit;
                 $width = $widthLimit;
             }
             $y1 = $top - $height;
             $y2 = $top;
             $x1 = 25;
             $x2 = $x1 + $width;
             //coordinates after transformation are rounded by Zend
             $page->drawImage($image, $x1, $y1, $x2, $y2);
             $this->y = $y1 - 10;
         }
     }
 }
 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);
 }
 /**
  * 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;
 }
Exemple #24
0
 /**
  * inserts the logo from complete left to right
  *
  * @param Zend_Pdf_Page &$page current Zend_Pdf_Page object
  * @param mixed         $store store we need the config setting from
  *
  * @todo merge _insertLogoPositioned and _insertLogoFullWidth
  */
 protected function _insertLogoFullWidth(&$page, $store = null)
 {
     $imageRatio = (int) Mage::getStoreConfig('sales_pdf/firegento_pdf/logo_ratio', $store);
     $imageRatio = empty($imageRatio) ? 1 : $imageRatio;
     $maxwidth = 594 * $imageRatio / 100;
     $maxheight = 300;
     $image = Mage::getStoreConfig('sales/identity/logo', $store);
     if ($image and file_exists(Mage::getBaseDir('media', $store) . '/sales/store/logo/' . $image)) {
         $image = Mage::getBaseDir('media', $store) . '/sales/store/logo/' . $image;
         list($width, $height) = Mage::helper('firegento_pdf')->getScaledImageSize($image, $maxwidth, $maxheight);
         if (is_file($image)) {
             $image = Zend_Pdf_Image::imageWithPath($image);
             $logoPosition = Mage::getStoreConfig('sales_pdf/firegento_pdf/logo_position', $store);
             switch ($logoPosition) {
                 case 'center':
                     $startLogoAt = $this->margin['left'] + ($this->margin['right'] - $this->margin['left']) / 2 - $width / 2;
                     break;
                 case 'right':
                     $startLogoAt = $this->margin['right'] - $width;
                     break;
                 default:
                     $startLogoAt = 0;
             }
             $position['x1'] = $startLogoAt;
             $position['y1'] = 663;
             $position['x2'] = $position['x1'] + $width;
             $position['y2'] = $position['y1'] + $height;
             $page->drawImage($image, $position['x1'], $position['y1'], $position['x2'], $position['y2']);
             $this->_marginTop = $height - 130;
         }
     }
 }
Exemple #25
0
 public function buildPageStructure($titles, $firstPage = false)
 {
     if (strtoupper($this->_deploy['size'] = 'LETTER') && strtoupper($this->_deploy['orientation']) == 'LANDSCAPE') {
         $this->_page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE);
     } elseif (strtoupper($this->_deploy['size'] = 'LETTER') && strtoupper($this->_deploy['orientation']) != 'LANDSCAPE') {
         $this->_page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
     } elseif (strtoupper($this->_deploy['size'] != 'A4') && strtoupper($this->_deploy['orientation']) == 'LANDSCAPE') {
         $this->_page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
     } else {
         $this->_page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     }
     if ($firstPage === true) {
         return;
     }
     $this->_page->setStyle($this->_styles['style']);
     $this->_pdf->pages[] = $this->_page;
     $this->_currentPage++;
     $this->_font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $this->_page->setFont($this->_font, $this->getDeployOption('headerFontSize', 14));
     if (file_exists($this->_deploy['logo'])) {
         $image = Zend_Pdf_Image::imageWithPath($this->_deploy['logo']);
         list($this->_width, $this->_height, $type, $attr) = getimagesize($this->_deploy['logo']);
         $this->_page->drawImage($image, 40, $this->_page->getHeight() - $this->_height - 40, 40 + $this->_width, $this->_page->getHeight() - 40);
     }
     $this->_page->drawText($this->__($this->_deploy['title']), $this->_width + 70, $this->_page->getHeight() - 70, $this->getCharEncoding());
     $this->_page->setFont($this->_font, $this->_cellFontSize);
     $this->_page->drawText($this->__($this->_deploy['subtitle']), $this->_width + 70, $this->_page->getHeight() - 80, $this->getCharEncoding());
     $this->_height = $this->_page->getHeight() - 120;
     $this->_page->drawText($this->__($this->_deploy['footer']), 40, 40, $this->getCharEncoding());
     if ($this->_deploy['noPagination'] != 1) {
         $this->_page->drawText($this->__($this->_deploy['page']) . ' ' . $this->_currentPage . '/' . $this->_totalPages, $this->_page->getWidth() - strlen($this->__($this->_deploy['page'])) * $this->_cellFontSize - 50, 40, $this->getCharEncoding());
     }
     reset($titles);
     $i = 0;
     $largura1 = 40;
     $this->_page->setFont($this->_font, $this->_cellFontSize + 1);
     foreach ($titles as $title) {
         if ($title['field'] != $this->getInfo('hRow,field') && $this->getInfo('hRow,title') != '' || $this->getInfo('hRow,title') == '') {
             if ((int) $this->_la == 0) {
                 $largura1 = 40;
             } else {
                 @($largura1 = $this->_cell[$i - 1] + $largura1);
             }
             $this->_page->setStyle($this->_styles['topo']);
             $this->_page->drawRectangle($largura1, $this->_height - 8, $largura1 + $this->_cell[$i] + 1, $this->_height + 12);
             $this->_page->setStyle($this->_styles['style']);
             $this->_page->drawText($title['value'], $largura1 + 2, $this->_height, $this->getCharEncoding());
             $this->_la = $largura1;
             $i++;
         }
         $this->_page->setFont($this->_font, $this->_cellFontSize);
     }
 }
Exemple #26
0
 /**
  * Render PDF page from PNG label image
  *
  * @param Zend_Pdf $pdf
  * @param string $fileName
  */
 protected function _renderPage(Zend_Pdf $pdf, $fileName, $data = null)
 {
     $v = $this->getVendor();
     $image = Zend_Pdf_Image::imageWithPath($fileName);
     $pdfPW = $v->getPdfPageWidth();
     $pdfPH = $v->getPdfPageHeight();
     $page = $pdf->newPage($v->getPdfPageSize());
     $wp = $page->getWidth() / $pdfPW;
     $hp = $page->getHeight() / $pdfPH;
     $r = (int) $v->getPdfLabelRotate();
     $l = (double) $v->getPdfLabelLeft();
     $t = (double) $v->getPdfLabelTop();
     $w = (double) $v->getPdfLabelWidth();
     $h = (double) $v->getPdfLabelHeight();
     if (!is_null($data)) {
         extract($data);
         if (!empty($data['w'])) {
             if ($r == 90 || $r == 270) {
                 $pdfPW = $h + $t * 2;
             } else {
                 $pdfPW = $w + $l * 2;
             }
             $wp = $page->getWidth() / $pdfPW;
         }
         if (!empty($data['h'])) {
             if ($r == 90 || $r == 270) {
                 $pdfPH = $w + $l * 2;
             } else {
                 $pdfPH = $h + $t * 2;
             }
             $hp = $page->getHeight() / $pdfPH;
         }
     }
     if ($r == 90 || $r == 270) {
         $tmp = $w;
         $w = $h;
         $h = $tmp;
     }
     $b = $pdfPH - $t - $h;
     $page->drawImage($image, $l * $wp, $b * $hp, ($l + $w) * $wp, ($b + $h) * $hp);
     return $page;
 }
Exemple #27
0
 /**
  * Returns a {@link Zend_Pdf_Resource_Image} object by file path.
  *
  * @param string $filePath Full path to the image file.
  * @return Zend_Pdf_Resource_Image
  * @throws Zend_Pdf_Exception
  */
 public static function imageWithPath($filePath)
 {
     /**
      * use old implementation
      * @todo switch to new implementation
      */
     // require_once 'Zend/Pdf/Resource/ImageFactory.php';
     return Zend_Pdf_Resource_ImageFactory::factory($filePath);
     /* Create a file parser data source object for this file. File path and
      * access permission checks are handled here.
      */
     // require_once 'Zend/Pdf/FileParserDataSource/File.php';
     $dataSource = new Zend_Pdf_FileParserDataSource_File($filePath);
     /* Attempt to determine the type of image. We can't always trust file
      * extensions, but try that first since it's fastest.
      */
     $fileExtension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
     /* If it turns out that the file is named improperly and we guess the
      * wrong type, we'll get null instead of an image object.
      */
     switch ($fileExtension) {
         case 'tif':
             //Fall through to next case;
         //Fall through to next case;
         case 'tiff':
             $image = Zend_Pdf_Image::_extractTiffImage($dataSource);
             break;
         case 'png':
             $image = Zend_Pdf_Image::_extractPngImage($dataSource);
             break;
         case 'jpg':
             //Fall through to next case;
         //Fall through to next case;
         case 'jpe':
             //Fall through to next case;
         //Fall through to next case;
         case 'jpeg':
             $image = Zend_Pdf_Image::_extractJpegImage($dataSource);
             break;
         default:
             // require_once 'Zend/Pdf/Exception.php';
             throw new Zend_Pdf_Exception("Cannot create image resource. File extension not known or unsupported type.");
             break;
     }
     /* Done with the data source object.
      */
     $dataSource = null;
     if ($image !== null) {
         return $image;
     } else {
         /* The type of image could not be determined. Give up.
          */
         // require_once 'Zend/Pdf/Exception.php';
         throw new Zend_Pdf_Exception("Cannot determine image type: {$filePath}", Zend_Pdf_Exception::CANT_DETERMINE_IMAGE_TYPE);
     }
 }
 public function getPdfPicklist($order)
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoices');
     $pdf = new Zend_Pdf();
     $this->_setPdf($pdf);
     $style = new Zend_Pdf_Style();
     $this->_setFontBold($style, 10);
     if ($order->getStoreId()) {
         Mage::app()->getLocale()->emulate($order->getStoreId());
     }
     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     $pdf->pages[] = $page;
     /***********************************************************
      * CONFIGURATIONS
      ***********************************************************/
     // all y values must be positive, all x positive
     // bottom left is 0,0
     ## DEFAULT VALUES
     $columnYNudgeDefault = 600;
     $barcodeXYDefault = '468,800';
     $orderDateXYDefault = '160,755';
     $orderIdXYDefault = '40,755';
     $addressXYDefault = '40,705';
     $addressFooterXYDefault = '50,105';
     // * new
     $returnAddressFooterXYDefault = '320,105';
     // * new
     $cutoff_noDefault = 10;
     $fontsize_overallDefault = 9;
     $fontsize_productlineDefault = 9;
     $fontsize_returnaddressDefault = 9;
     $fontsize_returnaddresstopDefault = 7;
     $fontsize_shipaddressDefault = 13;
     $skuXDefault = 300;
     $qtyXDefault = 40;
     $productXDefault = 80;
     $colorXDefault = 345;
     $sizeXDefault = 430;
     $priceXDefault = 505;
     $colorAttributeNameDefault = 'color';
     $sizeAttributeNameDefault = 'size';
     $showReturnLogoYNDefault = 'Y';
     $returnLogoXYDefault = '312,115';
     // hard-coded (not an option in config yet)
     $showPriceYNDefault = 'N';
     $showColorYNDefault = 'N';
     $showSizeYNDefault = 'N';
     $boldLastAddressLineYNDefault = 'Y';
     $fontsizeTitlesDefault = 14;
     $fontColorGrey = 0.8;
     $fontColorReturnAddressFooter = 0.2;
     //
     $showPriceYN = $showPriceYNDefault;
     $showColorYN = $showColorYNDefault;
     $showSizeYN = $showSizeYNDefault;
     $boldLastAddressLineYN = $boldLastAddressLineYNDefault;
     $fontsize_returnaddresstop = $fontsize_returnaddresstopDefault;
     $fontsizeTitles = $fontsizeTitlesDefault;
     // $page->drawImage($image, $left [x1], $bottom[y1], $right[x2], $top[y2]);
     ## DEFAULT VALUES from top left
     /*
     $columnYNudgeDefault        = 570;
     $barcodeXYDefault           = '450,800';
     $orderDateXYDefault         = '390,755';
     $orderIdXYDefault           = '390,730';
     $customerIdXYDefault        = '390,705'; 
     $customerNameXYDefault      = '130,648'; 
     $addressXYDefault           = '130,633';           
     $orderIdFooterXYDefault     = '106,76';
     $customerIdFooterXYDefault  = '106,47';            
     
     $cutoff_noDefault           = 10;
     $fontsize_overallDefault    = 9;
     $fontsize_productlineDefault= 9;
     $skuXDefault                = 90;
     $qtyXDefault                = 40;
     $productXDefault            = 230;
     $colorXDefault              = 345;
     $sizeXDefault               = 430;
     $priceXDefault              = 505;          
     */
     $columnYNudge = $this->_getConfig('pack_column', $columnYNudgeDefault);
     $showBarCode = $this->_getConfig('pickpack_packbarcode', 0, false);
     $barcodeXY = explode(",", $this->_getConfig('pack_barcode', $barcodeXYDefault));
     $orderDateXY = explode(",", $this->_getConfig('pack_order', $orderDateXYDefault));
     $customerIdXY = explode(",", $this->_getConfig('pack_cid', $customerIdXYDefault));
     $orderIdXY = explode(",", $this->_getConfig('pack_oid', $orderIdXYDefault));
     $color_attribute_name = $this->_getConfig('color_attribute_name', $colorAttributeNameDefault, false);
     $size_attribute_name = $this->_getConfig('size_attribute_name', $sizeAttributeNameDefault, false);
     $customerNameXY = explode(",", $this->_getConfig('pack_customer', $customerNameXYDefault));
     $addressXY = explode(",", $this->_getConfig('pack_customeraddress', $addressXYDefault));
     // $customerIdFooterXY 	=  explode(",", $this->_getConfig('footer_customer_id', $customerIdFooterXYDefault));
     $addressFooterXY = explode(",", $this->_getConfig('footer_address', $addressFooterXYDefault));
     // $orderIdFooterXY    	=  explode(",", $this->_getConfig('footer_order_id', $orderIdFooterXYDefault));
     $cutoff_no = $this->_getConfig('pack_noofitems', $cutoff_noDefault, false);
     $fontsize_overall = $this->_getConfig('pickpack_fontsizeoverall', $fontsize_overallDefault, false);
     $fontsize_productline = $this->_getConfig('pickpack_fontsizeproductline', $fontsize_productlineDefault, false);
     $fontsize_returnaddress = $this->_getConfig('pickpack_returnfont', $fontsize_returnaddressDefault, false);
     $fontsize_shipaddress = $this->_getConfig('pickpack_shipfont', $fontsize_shipaddressDefault, false);
     $skuX = $this->_getConfig('pack_sku', $skuXDefault);
     $qtyX = $this->_getConfig('pack_qty', $qtyXDefault);
     $productX = $this->_getConfig('pack_product', $productXDefault);
     $colorX = $this->_getConfig('pack_color', $colorXDefault);
     $sizeX = $this->_getConfig('pack_size', $sizeXDefault);
     $priceX = $this->_getConfig('pack_price', $priceXDefault);
     $showReturnLogoYN = $this->_getConfig('pickpack_returnlogo', $showReturnLogoYNDefault, 0, false);
     $returnLogoXY = explode(",", $this->_getConfig('pickpack_nudgelogo', $returnLogoXYDefault));
     $returnAddressFooterXY = explode(",", $this->_getConfig('pickpack_returnaddress', $returnAddressFooterXYDefault));
     $this->y = $page->getHeight();
     /***********************************************************
      * CONFIGURATIONS
      ***********************************************************/
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
     $this->_setFontRegular($page, $fontsize_overall);
     # BARCODE
     if (1 == $showBarCode) {
         $barcodeString = $this->convertToBarcodeString($order->getRealOrderId());
         #$page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
         $page->setFont(Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/' . 'Code128bWin.ttf'), 16);
         #$this->y += $barcodeXY[1];
         $page->drawText($barcodeString, $barcodeXY[0], $barcodeXY[1], 'CP1252');
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         $this->_setFontRegular($page, $fontsize_overall);
     }
     # HEADER
     // draw box behind order ID#
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.92));
     $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.92));
     $page->drawRectangle(20, $orderIdXY[1] - 5, 570, $orderIdXY[1] + 18);
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
     $this->_setFontBold($page, $fontsizeTitles + 4);
     $page->drawText('/   ' . Mage::helper('core')->formatDate($order->getCreatedAtStoreDate(), 'medium', false), $orderDateXY[0], $orderDateXY[1], 'UTF-8');
     $page->drawText('#' . $order->getRealOrderId(), $orderIdXY[0], $orderIdXY[1], 'UTF-8');
     $this->_setFontRegular($page, $fontsize_overall);
     // header logo
     $this->insertLogo($page, $order->getStore());
     // HEADER STORE ADDRESS
     // $store_address = $this->insertAddress($page, 'top', $order->getStore());
     $this->y = 820;
     $this->_setFontRegular($page, $fontsize_returnaddresstop);
     foreach (explode("\n", Mage::getStoreConfig('sales/identity/address', $order->getStore())) as $value) {
         if ($value !== '') {
             $page->drawText(trim(strip_tags($value)), 320, $this->y, 'UTF-8');
             $this->y -= 6;
         }
     }
     $this->_setFontRegular($page, $fontsize_overall);
     // HEADER LINES
     // return address
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
     $page->setLineWidth(12);
     $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.8));
     $page->drawLine(310, 795, 310, 825);
     // $page->setLineWidth(0);
     # HEADER SHIPPING ADDRESS
     $shippingAddressFlat = implode(',', $this->_formatAddress($order->getShippingAddress()->format('pdf')));
     $shippingAddressArray = explode(',', str_replace(',', '~,', $shippingAddressFlat));
     $this->_setFontBold($page, $fontsizeTitles);
     $page->drawText('shipping address', $addressXY[0], $addressXY[1] + 20, 'UTF-8');
     $this->_setFontRegular($page, $fontsize_overall);
     $line_height = 0;
     foreach ($shippingAddressArray as $item) {
         if ($addressXY[1] - $line_height > 0 && $addressXY[0] > 0) {
             $item = trim(str_replace('~', ',', $item));
             $page->drawText($item, $addressXY[0], $addressXY[1] - $line_height, 'UTF-8');
             $line_height = $line_height + $fontsize_overall;
         }
     }
     # FOOTER
     // order ID / address
     $page->setFillColor(new Zend_Pdf_Color_Rgb($fontColorGrey, $fontColorGrey, $fontColorGrey));
     $this->_setFontBold($page, $fontsizeTitles - 3);
     $page->drawText('#' . $order->getRealOrderId(), $addressFooterXY[0], $addressFooterXY[1] + 20, 'UTF-8');
     $this->_setFontRegular($page, $fontsize_overall);
     $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
     $line_height = 0;
     $item_prev = '';
     $this->_setFontRegular($page, $fontsize_shipaddress);
     $i = 0;
     while ($shippingAddressArray[$i]) {
         if (isset($shippingAddressArray[$i]) && $addressFooterXY[1] - $line_height > 0 && $addressFooterXY[0] > 0) {
             if (preg_match('~T:~', $shippingAddressArray[$i])) {
                 // phone line, grey it bracket it
                 $shippingAddressArray[$i] = trim(str_replace('~', '', $shippingAddressArray[$i]));
                 $line_height = $line_height + $fontsize_shipaddress / 2;
                 $this->_setFontRegular($page, $fontsize_shipaddress - 2);
                 $page->setFillColor(new Zend_Pdf_Color_Rgb($fontColorGrey - 0.2, $fontColorGrey - 0.2, $fontColorGrey - 0.2));
                 $shippingAddressArray[$i] = '[ ' . $shippingAddressArray[$i] . ' ]';
             } else {
                 // regular line or last line
                 $this->_setFontRegular($page, $fontsize_shipaddress);
                 if (!isset($shippingAddressArray[$i + 1]) || preg_match('~T:~', $shippingAddressArray[$i + 1])) {
                     // last line, lets bold it and make it a bit bigger
                     $shippingAddressArray[$i] = trim(str_replace('~', '', $shippingAddressArray[$i]));
                     if ($boldLastAddressLineYN == 'Y') {
                         $this->_setFontBold($page, $fontsize_shipaddress + 2);
                         $line_height = $line_height + 2;
                     }
                 } else {
                     $shippingAddressArray[$i] = trim(str_replace('~', ',', $shippingAddressArray[$i]));
                 }
                 $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
             }
             $page->drawText($shippingAddressArray[$i], $addressFooterXY[0], $addressFooterXY[1] - $line_height, 'UTF-8');
             $line_height = $line_height + $fontsize_shipaddress;
         }
         $i++;
     }
     $page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
     // footer return address logo
     if ($showReturnLogoYN == 'Y') {
         $image = Mage::getStoreConfig('pickpack_options/wonder/pickpack_logo', $order->getStore());
         if ($image) {
             $image = Mage::getStoreConfig('system/filesystem/media', $order->getStore()) . '/sales/store/logo_third/' . $image;
             if (is_file($image)) {
                 $image = Zend_Pdf_Image::imageWithPath($image);
                 // $page->drawImage($image, 315+$newlogo[1], 180+$newlogo[0], 500+$newlogo[0], 200+$newlogo[0]);
                 $page->drawImage($image, $returnLogoXY[0], $returnLogoXY[1], $returnLogoXY[0] + 185, $returnLogoXY[1] + 20);
             }
         }
     }
     // footer store address
     $this->_setFontRegular($page, $fontsize_returnaddress);
     $page->setFillColor(new Zend_Pdf_Color_Rgb($fontColorReturnAddressFooter, $fontColorReturnAddressFooter, $fontColorReturnAddressFooter));
     // $store_address = $this->insertAddress($page, 'bottom', $order->getStore());
     // $this->y = 105;
     $page->drawText('From :', $returnAddressFooterXY[0], $returnAddressFooterXY[1], 'UTF-8');
     // $this->y -=18;
     $line_height = 15;
     foreach (explode("\n", Mage::getStoreConfig('sales/identity/address', $order->getStore())) as $value) {
         if ($value !== '') {
             $page->drawText(trim(strip_tags($value)), $returnAddressFooterXY[0], $returnAddressFooterXY[1] - $line_height, 'UTF-8');
             $line_height = $line_height + $fontsize_returnaddress;
         }
     }
     $this->_setFontRegular($page, $fontsize_overall);
     # ITEMS
     $this->y = $columnYNudge;
     $this->_itemsY = $this->y;
     // draw box behind table headers
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.92));
     $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.92));
     $page->drawRectangle(20, $columnYNudge - 2, 570, $columnYNudge + 10);
     /* Add table head */
     $page->setFillColor(new Zend_Pdf_Color_Rgb($fontColorGrey - 0.5, $fontColorGrey - 0.5, $fontColorGrey - 0.5));
     $this->_setFontBold($page, $fontsizeTitles);
     $page->drawText(Mage::helper('sales')->__('qty'), $qtyX, $this->y, 'UTF-8');
     $page->drawText(Mage::helper('sales')->__('items'), $productX, $this->y, 'UTF-8');
     $page->drawText(Mage::helper('sales')->__('codes'), $skuX, $this->y, 'UTF-8');
     if ($showPriceYN == 'Y') {
         $page->drawText(Mage::helper('sales')->__('Price'), $priceX, $this->y, 'UTF-8');
     }
     $this->y = $this->y - 28;
     $counter = 1;
     $itemsCollection = $order->getAllVisibleItems();
     //$order->getItemsCollection();
     $total_items = count($itemsCollection);
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
     $this->_setFontRegular($page, $fontsize_productline);
     foreach ($itemsCollection as $item) {
         $size = '';
         $color = '';
         $options = $item->getProductOptions();
         $color_attribute_id = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $color_attribute_name)->getAttributeId();
         //272
         $size_attribute_id = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $size_attribute_name)->getAttributeId();
         //525
         $size_id = $options['info_buyRequest']['super_attribute'][$size_attribute_id];
         #size
         $color_id = $options['info_buyRequest']['super_attribute'][$color_attribute_id];
         #color
         $sizeCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')->setStoreFilter(0)->setAttributeFilter($size_attribute_id)->load();
         foreach ($sizeCollection as $_size) {
             if ($_size->getOptionId() == $size_id) {
                 $size = $_size->getValue();
                 break;
             }
         }
         $colorCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')->setStoreFilter(0)->setAttributeFilter($color_attribute_id)->load();
         foreach ($colorCollection as $_color) {
             if ($_color->getOptionId() == $color_id) {
                 $color = $_color->getValue();
                 break;
             }
         }
         $qty = $item->getIsQtyDecimal() ? $item->getQtyOrdered() : (int) $item->getQtyOrdered();
         $page->drawText($qty, $qtyX + 8, $this->y, 'UTF-8');
         $page->drawText($item->getSku(), $skuX, $this->y, 'UTF-8');
         $page->drawText($item->getName(), $productX, $this->y, 'UTF-8');
         if ($showColorYN == 'Y') {
             $page->drawText($color, $colorX, $this->y, 'UTF-8');
         }
         if ($showSizeYN == 'Y') {
             $page->drawText($size, $sizeX, $this->y, 'UTF-8');
         }
         // show price if set to show
         if ($showPriceYN == 'Y') {
             $price = $qty * $item->getPriceInclTax();
             $page->drawText(number_format($price, 2, '.', ','), $priceX, $this->y, 'UTF-8');
         }
         $this->y -= 15;
         if ($counter % $cutoff_no == 0 && $counter != $total_items) {
             $page = $this->newPage2();
         }
         $counter++;
     }
     #exit;
     /***********************************************
      * PickList Template - END
      ************************************************/
     $this->_afterGetPdf();
     return $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;
 }
Exemple #30
0
 /**
  * Draw an image at the specified position on the page.
  *
  * @param Zend_Pdf_Image $image
  * @param float $x1
  * @param float $y1
  * @param float $x2
  * @param float $y2
  */
 public function drawImage(Zend_Pdf_Image $image, $x1, $y1, $x2, $y2)
 {
     $this->_addProcSet('PDF');
     $imageName = $this->_attachResource('XObject', $image->getResource());
     $imageNameObj = new Zend_Pdf_Element_Name($imageName);
     $x1Obj = new Zend_Pdf_Element_Numeric($x1);
     $y1Obj = new Zend_Pdf_Element_Numeric($y1);
     $widthObj = new Zend_Pdf_Element_Numeric($x2 - $x1);
     $heightObj = new Zend_Pdf_Element_Numeric($y2 - $y1);
     $this->_contents .= "q\n" . '1 0 0 1 ' . $x1Obj->toString() . ' ' . $y1Obj->toString() . " cm\n" . $widthObj->toString() . ' 0 0 ' . $heightObj->toString() . " 0 0 cm\n" . $imageNameObj->toString() . " Do\n" . "Q\n";
 }