public function process()
 {
     $configuracao = Doctrine::getTable('Configuracao')->find(1);
     $this->document->pages[] = $page = $this->document->newPage(\Zend_Pdf_Page::SIZE_A4);
     //monta o cabecalho
     $color = array();
     $color["black"] = new Zend_Pdf_Color_Html("#000000");
     $fontTitle = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $size = 12;
     $styleTitle = new Zend_Pdf_Style();
     $styleTitle->setFont($fontTitle, $size);
     $styleTitle->setFillColor($color["black"]);
     $page->setStyle($styleTitle);
     $page->drawText($configuracao->instituicao, Documento::DOCUMENT_LEFT, Documento::DOCUMENT_TOP, 'UTF-8');
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
     $style = new Zend_Pdf_Style();
     $style->setFont($font, $size);
     $style->setFillColor($color["black"]);
     $page->setStyle($style);
     $text = wordwrap($this->text, 95, "\n", false);
     $token = strtok($text, "\n");
     $y = 665;
     while ($token != false) {
         if ($y < 100) {
             $this->document->pages[] = $page = $this->document->newPage(Zend_Pdf_Page::SIZE_A4);
             $page->setStyle($style);
             $y = 665;
         } else {
             $y -= 15;
         }
         $page->drawText($token, 60, $y, 'UTF-8');
         $token = strtok("\n");
     }
 }
Exemplo n.º 2
0
 public function setStyle()
 {
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
     $style->setFillColor(new Zend_Pdf_Color_Html('#333333'));
     $style->setLineColor(new Zend_Pdf_Color_Html('#990033'));
     $style->setLineWidth(1);
     $this->_page->setStyle($style);
 }
 public function getPdf($bidon = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     //on cree le pdf que si il n'est pas déja défini( ca permet de mettre plrs documents dans le mm pdf (genre une facture, un BL ....)
     if ($this->pdf == null) {
         $this->pdf = new Zend_Pdf();
     }
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     //cree la nouvelle page
     $titre = mage::helper('purchase')->__('Picking List');
     $settings = array();
     $settings['title'] = $titre;
     $settings['store_id'] = 0;
     $page = $this->NewPage($settings);
     //affiche l'entete du tableau
     $this->drawTableHeader($page);
     $this->y -= 10;
     //Affiche le récap des produits
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
     //charge la collection des produits
     $collection = Mage::getModel('Orderpreparation/ordertoprepare')->GetProductsSummary();
     foreach ($collection as $product) {
         //dessine
         $page->drawText($product->getqty_to_prepare(), 15, $this->y, 'UTF-8');
         $page->drawText($product->getAttributeText('manufacturer'), 70, $this->y, 'UTF-8');
         $page->drawText($product->getSku(), 180, $this->y, 'UTF-8');
         $page->drawText($product->getName(), 310, $this->y, 'UTF-8');
         //rajoute une ligne de séparation
         $page->setLineWidth(0.5);
         $page->drawLine(10, $this->y - 4, $this->_BLOC_ENTETE_LARGEUR, $this->y - 4);
         $this->y -= $this->_ITEM_HEIGHT;
         //si on a plus la place de rajouter le footer, on change de page
         if ($this->y < $this->_BLOC_FOOTER_HAUTEUR + 40) {
             $this->drawFooter($page);
             $page = $this->NewPage($settings);
             $this->drawTableHeader($page);
         }
     }
     //dessine le pied de page
     $this->drawFooter($page);
     //rajoute la pagination
     $this->AddPagination($this->pdf);
     $this->_afterGetPdf();
     return $this->pdf;
 }
 public function getPdf($orders = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     //on cree le pdf que si il n'est pas déja défini( ca permet de mettre plrs documents dans le mm pdf (genre une facture, un BL ....)
     $this->pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     //cree la nouvelle page
     $titre = mage::helper('purchase')->__('Order Comments');
     $settings = array();
     $settings['title'] = $titre;
     $settings['store_id'] = 0;
     $page = $this->NewPage($settings);
     $this->y -= $this->_ITEM_HEIGHT * 2;
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
     //Rajoute les commandes avec commentaires
     foreach ($orders as $order) {
         $comments = mage::helper('Organizer')->getEntityCommentsSummary('order', $order->getorder_id(), false);
         if ($comments != '') {
             $realOrder = mage::getModel('sales/order')->load($order->getorder_id());
             $page->drawText(mage::helper('purchase')->__('Order # ') . $realOrder->getIncrementId(), 15, $this->y, 'UTF-8');
             $comments = $this->WrapTextToWidth($page, $comments, 450);
             $offset = $this->DrawMultilineText($page, $comments, 150, $this->y, 10, 0.2, 11);
             $this->y -= 8 + $offset;
             $page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
             $this->y -= 15;
         }
     }
     //dessine le pied de page
     $this->drawFooter($page);
     //rajoute la pagination
     $this->AddPagination($this->pdf);
     $this->_afterGetPdf();
     return $this->pdf;
 }
Exemplo n.º 5
0
    }
} else {
    foreach ($pdf->pages as $num => $obj) {
        $obj->setStyle($bulletin_style);
        $obj->drawRectangle(30, 32, 150, 20);
        $obj->setFillColor($black);
        $obj->drawText($stamp, 32, 24);
        // stamp
        $pdf->pages[$num] = $obj;
        // save
    }
}
// 5a. note on the time exception
if ($display_name == "A-Note-on-the-Time") {
    $style = new Zend_Pdf_Style();
    $style->setFont(Zend_Pdf_Font::fontWithPath($note_font_path), $note_font_size);
    $style->setFillColor($white);
    $boxes = array();
    $stampText = date('Y M d g:i A', $now);
    $date1 = "2011-02-18 3:34";
    // the time of writing
    $date2 = date('Y-M-d g:i', $now);
    $daylightSaving = date('I');
    $diff = abs(strtotime($date2) - strtotime($date1));
    $days = floor($diff / (60 * 60 * 24));
    $hours = floor(($diff - $days * 60 * 60 * 24) / (60 * 60));
    $minutes = floor(($diff - $days * 60 * 60 * 24 - $hours * 60 * 60) / 60);
    $hours = $hours + $daylightSaving;
    $stampTextD = $days . " days, " . $hours . " hours, " . $minutes . " minutes.";
    // 2d array -- page, x, y, w, h, text
    $boxes = array(array(p => 2, x => 89, y => 602, w => 114, h => 15, t => $stampText), array(p => 4, x => 174, y => 482, w => 114, h => 15, t => $stampText), array(p => 5, x => 169, y => 617, w => 114, h => 15, t => $stampText), array(p => 6, x => 51, y => 362, w => 114, h => 15, t => $stampText), array(p => 6, x => 120, y => 77, w => 152, h => 15, t => $stampTextD));
 /**
  *  method to stamp each pdf page (add a banner with timestamp user real name and  confidentiality level)
  *  @param  void
  *  @return void
  */
 public function stamp($values)
 {
     // Prepare stamp
     if ($values != null) {
         $first = true;
         foreach ($values as $value) {
             if ($first) {
                 $sep = '';
                 $first = false;
             } else {
                 $sep = ', ';
             }
             $valueTxt = $sep . $value->getName();
         }
     } else {
         $valueTxt = '';
     }
     $text = "Downloaded on " . date("d M Y H:i", $_SERVER['REQUEST_TIME']) . " by " . $this->user->getRealName() . " " . $valueTxt;
     $stamp = $text . " // " . $text;
     // Text and box style
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     $style->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     $style->setLineColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
     //get pdf watermarking level based on number of pages in pdf document.
     $watermarkingLevel = $this->getWatermarkingLevelFromPdfSize();
     // Stamp with adequate watermarking level
     switch ($watermarkingLevel) {
         case self::WATERMARK_EVERYPAGE:
             // Apply it on all pages
             foreach ($this->pdf->pages as $page) {
                 $this->stampOnePage($page, $style, $stamp);
             }
             break;
         case self::WATERMARK_EVERY_TWO_PAGES:
             $count = 0;
             foreach ($this->pdf->pages as $page) {
                 if ($count % 2 == 0) {
                     $this->stampOnePage($page, $style, $stamp);
                 }
                 $count++;
             }
             break;
         case self::WATERMARK_THIRTY_PERCENT_OF_PAGES:
             $pagesToWatermark = $this->getPagesToWatermark(0.3, count($this->pdf->pages));
             foreach ($pagesToWatermark as $pageNo) {
                 $this->stampOnePage($this->pdf->pages[$pageNo], $style, $stamp);
             }
             break;
         case self::WATERMARK_TEN_PERCENT_OF_PAGES:
         default:
             $pagesToWatermark = $this->getPagesToWatermark(0.1, count($this->pdf->pages));
             foreach ($pagesToWatermark as $pageNo) {
                 $this->stampOnePage($this->pdf->pages[$pageNo], $style, $stamp);
             }
             break;
     }
 }
Exemplo n.º 7
0
 public function byProduct($product, $for_catalog = false)
 {
     $category = $product->findManyToManyRowset("Model_DbTable_Categories", "Model_DbTable_CategoryXref")->current();
     if ($category) {
         $this->category = $category->getBcnName();
     } else {
         $this->category = "Неизвестно";
     }
     $productParams = $product->getParams();
     if (!$for_catalog) {
         $this->margins = array('top' => 35, 'right' => 20, 'bottom' => 35, 'left' => 20);
     }
     if (is_null($this->book)) {
         $page = $this->createBook(1, $for_catalog);
     } else {
         $page = $this->lastPage();
     }
     $offset = $for_catalog == false ? 0 : $page->getHeight() - $page->getCurrentPosition() - 1;
     if (!$for_catalog) {
         $page->setMargins(35, 20, 35, 20);
     }
     $noteStyle = new Zend_Pdf_Style();
     $noteStyle->setFont(Model_Static_Fonts::get("Arial Narrow"), $this->format == 'A4' ? 6.5 : 4.5);
     $noteStyle->setLineWidth($page->getWidth() - 20);
     $style = new Zend_Pdf_Style();
     $style->setFont(Model_Static_Fonts::get("Arial Narrow"), $this->format == 'A4' ? 8.0 : 6.5);
     $style->setLineWidth($page->getWidth());
     $paramsLinesCount = 0;
     foreach ($productParams as $param) {
         $paramsLinesCount += count(explode("\n", $param->value));
     }
     $paramsLinesCount++;
     $subproductsModel = new Model_DbTable_Subproducts();
     $select = $subproductsModel->select()->order('order ASC');
     $subProducts = $product->findDependentRowset("Model_DbTable_Subproducts", 'SubproductsRel', $select);
     // расчет высоты всего продукта, проверка влезает ли он на страницу, если не влезает смотрим сколько именно не влезает и есть ли субпродукты,
     // которые мы може отрисовать на этой странице и перенести отстаток на другую страницу
     $productHeightWithoutTable = 10 + max(array(80, $this->format == 'A4' ? $paramsLinesCount * 12 : $paramsLinesCount * 8)) + ($product->description ? $page->getTextBlockHeight(trim($product->description), $style, 3) : 0);
     $productHeight = 20 + max(array(80, $this->format == 'A4' ? $paramsLinesCount * 12 : $paramsLinesCount * 8)) + ($product->description ? $page->getTextBlockHeight(trim($product->description), $style, 3) : 0) + (count($subProducts) <= 30 ? $this->format == 'A4' ? count($subProducts) * 12 + 10 : count($subProducts) * 8 + 12 + 15 : 0) + ($product->note ? $page->getTextBlockHeight($product->note, $noteStyle) + 10 : 0);
     // note*/
     if ($offset) {
         if ($page->getHeight() - $offset - 10 < (count($subProducts) <= 30 ? $productHeight : intval($productHeight) + 40)) {
             if ($page->getPageNumber() > 1) {
                 $page->drawCategory(isset($this->old_category) ? $this->old_category : $this->category);
                 $this->old_category = NULL;
                 $page = $this->addPage();
                 $offset = 0;
             }
         } else {
             if ($page->getCurrentPosition() < 700 && $for_catalog) {
                 $offset -= 5;
             }
             $page->init($offset);
             $this->old_category = $this->category;
         }
     } else {
         $this->old_category = $this->category;
     }
     $this->product_page = $page->getPageNumber();
     // DEBUG auto-height calculate
     if (isset($_REQUEST['DEBUG'])) {
         $page->drawHorizontalLine(-20, 575, $page->getHeight() - $offset, 1, new Zend_Pdf_Color_Html('green'));
         $page->drawHorizontalLine(-20, 575, $page->getHeight() - $offset - $productHeight, 2, new Zend_Pdf_Color_Html('red'));
         $page->drawTextBlock(count($subProducts), -20, $page->getHeight() - $offset - $productHeight);
     }
     // --- block / information
     $page->setFont(Model_Static_Fonts::get("Franklin Gothic Demi Cond"), 14);
     $page->drawTextBlock($product->sku, 5, $page->getHeight() - $offset);
     $page->setFont(Model_Static_Fonts::get("Franklin Gothic Demi Cond"), 10);
     $page->drawTextBlock($product->name, 5, $page->getHeight() - 10 - $offset);
     // --- block / images
     $images = array($product->image);
     if ($product->a_images) {
         $images[] = $product->a_images[0];
     }
     $x = 0;
     if ($page->getPageNumber() % 2 == 0) {
         // если картинки справа (иконки слева)
         $images = array_reverse($images);
         // здесь нужно посчитать правильные ширины отступов начала изображений
         $x = $page->getWidth() - 5;
         foreach ($images as $image) {
             $sizes = $page->picSize($this->getProductImageFullpath($image), $this::IMAGE_SIZE, $this::IMAGE_SIZE, 2);
             //$x = $x - $this::IMAGE_SIZE * $sizes[0];
             $x = $x - $this::IMAGE_SIZE;
             //echo $image." ";
         }
         $x = $x - 5 * (count($images) - 1);
     } else {
         // картинки слева - просто задаем базовый отступ по x
         $x += 5;
     }
     //echo $x." ";
     $count = 0;
     // count of images (x75)
     //в зависимости от задачи, выбираем папку с картинками, за это отвечает параметр $print
     foreach ($images as $image) {
         if ($this->print) {
             //$c = $page -> drawPic(APPLICATION_ROOT . '/files/images/product_tiff/' . substr($image, 0, strripos($image, ".")).'.tif', $x, $page -> getHeight() - 20 - $offset, $this::IMAGE_SIZE, $this::IMAGE_SIZE, isset($images[1]) ? 1 : 2,1);
             $c = $page->drawPic($this->getProductImageFullpath($image), $x, $page->getHeight() - 20 - $offset, $this::IMAGE_SIZE, $this::IMAGE_SIZE, 2, 1);
         } else {
             $c = $page->drawPic($this->getProductImageFullpath($image), $x, $page->getHeight() - 20 - $offset, $this::IMAGE_SIZE, $this::IMAGE_SIZE, isset($images[1]) ? 1 : 2, 1);
         }
         if ($page->getPageNumber() % 2 == 0) {
             // если картинки справа, то не считаем полную ширину
             $x += $this::IMAGE_SIZE + 5;
         } else {
             $x += $this::IMAGE_SIZE * $c + 5;
         }
         $count += $c;
     }
     // --- block / params
     $offsetX = $page->getPageNumber() % 2 ? $this::IMAGE_SIZE * $count + 15 : 10;
     $tableWidth = $page->getWidth() - $this::IMAGE_SIZE * $count - 25;
     if (count($productParams) > 0) {
         $params = array();
         foreach ($productParams as $productParam) {
             $params[] = array($productParam->name, str_replace(array(' ' . chr('0x0D') . chr('0x0A'), chr('0x0D') . chr('0x0A')), ', ', $productParam->value));
         }
         $page->drawTable($params, $offsetX, $page->getHeight() - 30 - $offset, $tableWidth);
     }
     // --- block / description
     if ($product->description) {
         $style = new Zend_Pdf_Style();
         $style->setFont(Model_Static_Fonts::get("Arial Narrow"), $this->format == 'A4' ? 8.0 : 6.5);
         $style->setLineWidth($page->getWidth());
         if ($for_catalog) {
             $page->drawTextBlock(str_replace(array('      ', '       ', '        '), '. ', trim($product->description)), 5, $page->getCurrentPosition() + 25, $style, 3);
             //chr('0x0D').chr('0x0A')
             $page->setCurrentPosition($page->getCurrentPosition() + 10);
         } else {
             $page->drawTextBlock(str_replace(array('      ', '       ', '        '), chr('0x0D') . chr('0x0A'), trim($product->description)), 5, $page->getCurrentPosition() + 15, $style, 3);
             $page->setCurrentPosition($page->getCurrentPosition() + 15);
         }
     }
     // --- block / sub products
     $params = array();
     $subproductParams = $product->getSubParams();
     foreach ($subProducts as $subProduct) {
         $productParams = $subProduct->getParamsValues();
         $row = array($subProduct->sku);
         foreach ($productParams as $productParam) {
             $row[] = $productParam->value;
         }
         $params[] = $row;
     }
     if (count($subProducts) > 0) {
         $header = array('Название');
         foreach ($subproductParams as $subproductParam) {
             $header[] = $subproductParam->name;
         }
     }
     if ($product->note) {
         $noteHeight = $page->getTextBlockHeight($product->note, $noteStyle);
     } else {
         $noteHeight = 0;
     }
     //
     //	$noteHeight = 0;
     $curRow = 0;
     if ($params) {
         $page->setCurrentPosition($page->getCurrentPosition() + 20);
         // move table-description
         while ($curRow !== NULL) {
             $curRow = $page->drawTable($params, 0, $page->getCurrentPosition(), $page->getWidth() - 5, $noteHeight, $header, $curRow, true, $product->note);
             if ($curRow !== NULL) {
                 $page->drawCategory($this->category);
             }
             //		else {
             //	                if ($product -> note && $for_catalog) {
             //				$page -> drawTextBlock($product -> note, 5, $page -> getCurrentPosition() + 24, $noteStyle);
             //			}elseif($product -> note){
             //				$page -> drawTextBlock($product -> note, 5, $page -> getCurrentPosition() + 62, $noteStyle);
             //			}
             //		}
             //		$page -> drawTextBlock($curRow, -20, $page -> getHeight() - $offset - $productHeight);
             $page = $this->addPage(false);
             if ($curRow !== NULL) {
                 $curRow++;
             }
         }
     } else {
         $this->AddPage(false);
     }
     return $this->book;
 }
Exemplo n.º 8
0
 /**
  * Insert a claim details into a PDF.
  *
  * @param int $claimRefNo
  *
  * @return void
  */
 public function populateAndOuputClaimStatusReport($claimRefNo, $agentSchemeNumber)
 {
     $claimDataSource = new Datasource_Insurance_KeyHouse_Claim();
     $claimData = $claimDataSource->getClaim($claimRefNo, $agentSchemeNumber);
     $pdf = new Zend_Pdf_WrapText();
     // create A4 page
     $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
     // Add HomeLet logo
     $xcoord = 15;
     $ycoord = 780;
     $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../public/assets/common/images/logo-mid.png');
     $page->drawImage($image, $xcoord, $ycoord, $xcoord + $image->getPixelWidth(), $ycoord + $image->getPixelHeight());
     // define a style
     $claimHeaderFont = new Zend_Pdf_Style();
     $claimHeaderFont->setFillColor(Zend_Pdf_Color_Html::color('#FF6F1C'));
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $claimHeaderFont->setFont($font, 14);
     // define another style
     $claimContentTitleFont = new Zend_Pdf_Style();
     $claimContentTitleFont->setFillColor(Zend_Pdf_Color_Html::color('#0C2F6B'));
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
     $claimContentTitleFont->setFont($font, 10);
     // define another style
     $claimContentFont = new Zend_Pdf_Style();
     $claimContentFont->setFillColor(Zend_Pdf_Color_Html::color('#0C2F6B'));
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $claimContentFont->setFont($font, 10);
     // write title text to page
     $page->setStyle($claimHeaderFont)->drawText('Claim Status Report', 250, 810);
     // write content text to page
     $page->setStyle($claimContentTitleFont)->drawText('Claim Number', 15, 700);
     $page->setStyle($claimContentFont)->drawText($claimData[0]['ClaimNo'], 200, 700);
     $page->setStyle($claimContentTitleFont)->drawText('Claim Handler', 15, 680);
     $page->setStyle($claimContentFont)->drawText($claimData[0]['ClaimsHandler'], 200, 680);
     $page->setStyle($claimContentTitleFont)->drawText('Reference Number', 15, 660);
     $page->setStyle($claimContentFont)->drawText($claimData[0]['ClaimNo'], 200, 660);
     $page->setStyle($claimContentTitleFont)->drawText('Start Date', 15, 640);
     $page->setStyle($claimContentFont)->drawText($claimData[0]['ClaimDate'], 200, 640);
     $page->setStyle($claimContentTitleFont)->drawText('Date', 35, 590);
     $page->setStyle($claimContentTitleFont)->drawText('Action', 235, 590);
     $page->setStyle($claimContentTitleFont)->drawText('Status', 435, 590);
     // wrap text to avoid overlapping
     $zendWrapText = new Zend_Pdf_WrapText();
     $sectionHeight = 0;
     $y = 570;
     for ($i = 0; $i < count($claimData); $i++) {
         $page->setStyle($claimContentFont)->drawText($claimData[$i]['ClaimDate'], 35, $y);
         $sectionHeight = $zendWrapText->drawWrappedText($page, 235, $y, $claimData[$i]['Activity'], 150, $claimContentFont);
         //$page->setStyle($claimContentFont)->drawTextBlock($claimData[$i]['Activitiy'], 235, 570, 200, 200, Zend_Pdf_Page::ALIGN_LEFT);
         $page->setStyle($claimContentFont)->drawText($claimData[$i]['OpenOrClosed'], 435, $y);
         $y -= $sectionHeight;
     }
     // add page to document
     $pdf->pages[] = $page;
     $filename = "claimstatus_" . md5($claimRefNo);
     // send to browser as download
     return $pdf->render();
 }
 public function getPdf($order = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     $this->pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     //cree la nouvelle page
     $titre = mage::helper('purchase')->__('Order #') . $order->getincrement_id() . ' ' . mage::helper('purchase')->__('Comments');
     $settings = array();
     $settings['title'] = $titre;
     $settings['store_id'] = 0;
     $page = $this->NewPage($settings);
     //cartouche
     $txt_date = "Date :  " . mage::helper('core')->formatDate($order->getCreatedAt(), 'long');
     $txt_order = mage::helper('purchase')->__('Order #') . $order->getId();
     //$adresse_fournisseur = Mage::getStoreConfig('sales/identity/address');
     $customer = mage::getmodel('customer/customer')->load($order->getCustomerId());
     $adresse_client = mage::helper('purchase')->__('Shipping Address') . ":\n" . $this->FormatAddress($order->getShippingAddress(), '', false, $customer->gettaxvat());
     $adresse_fournisseur = mage::helper('purchase')->__('Billing Address') . ":\n" . $this->FormatAddress($order->getBillingAddress(), '', false, $customer->gettaxvat());
     $this->AddAddressesBlock($page, $adresse_fournisseur, $adresse_client, $txt_date, $txt_order);
     //Rajoute le carrier et la date d'expe prévue & les commentaires
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
     $this->y -= 15;
     $page->drawText(mage::helper('purchase')->__('Shipping') . ' : ' . $order->getShippingDescription(), 15, $this->y, 'UTF-8');
     $this->y -= 15;
     $comments = $this->WrapTextToWidth($page, $order->getmdn_comments(), 550);
     $offset = $this->DrawMultilineText($page, $comments, 15, $this->y, 10, 0.2, 11);
     $this->y -= 10 + $offset;
     $page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
     //affiche l'entete du tableau
     $this->drawTableHeader($page);
     $this->y -= 10;
     //Affiche le récap des produits
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
     foreach ($order->getAllItems() as $item) {
         //recupere le produit
         $product = mage::getModel('catalog/product')->load($item->getproduct_id());
         //dessine
         $page->drawText((int) $item->getqty_ordered(), 15, $this->y, 'UTF-8');
         $page->drawText($product->getSku(), 70, $this->y, 'UTF-8');
         $page->drawText($product->getName(), 200, $this->y, 'UTF-8');
         $page->drawText($item->getreserved_qty(), 560, $this->y, 'UTF-8');
         //rajoute les commentaires
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_ITALIC), 8);
         $this->y -= $this->_ITEM_HEIGHT;
         $caption = $this->WrapTextToWidth($page, $item->getcomments(), 300);
         $offset = $this->DrawMultilineText($page, $caption, 200, $this->y, 10, 0.2, 11);
         $this->y -= $offset;
         //rajoute une ligne de séparation
         $page->setLineWidth(0.5);
         $page->drawLine(10, $this->y - 4, $this->_BLOC_ENTETE_LARGEUR, $this->y - 4);
         $this->y -= $this->_ITEM_HEIGHT;
         //si on a plus la place de rajouter le footer, on change de page
         if ($this->y < $this->_BLOC_FOOTER_HAUTEUR + 40) {
             $this->drawFooter($page);
             $page = $this->NewPage($settings);
             $this->drawTableHeader($page);
         }
     }
     //dessine le pied de page
     $this->drawFooter($page);
     //rajoute la pagination
     $this->AddPagination($this->pdf);
     $this->_afterGetPdf();
     return $this->pdf;
 }
Exemplo n.º 10
0
}
if (file_exists($argv[1])) {
    $pdf = Zend_Pdf::load($argv[1]);
} else {
    $pdf = new Zend_Pdf();
}
//------------------------------------------------------------------------------------
// 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(new Zend_Pdf_Font_Standard(Zend_Pdf_Const::FONT_HELVETICA_BOLD), 32);
// Create new image object
$stampImage = new Zend_Pdf_Image_JPEG(dirname(__FILE__) . '/stamp.jpg');
// Mark page as modified
foreach ($pdf->pages as $page) {
    $page->saveGS();
    $page->setStyle($style);
    $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)
Exemplo n.º 11
0
 public function getPdf($data)
 {
     $this->_currentPage = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
     $style = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
     $style->setFont($fontH, 12);
     $color = Zend_Pdf_Color_Html::color('black');
     $style->setFillColor($color);
     $linkStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
     $linkStyle->setFont($fontH, 10);
     $color = Zend_Pdf_Color_Html::color('blue');
     $linkStyle->setFillColor($color);
     $linkStyle->setLineColor($color);
     $this->_initCoordinates();
     $this->addImage(Mage::getDesign()->getSkinUrl('images/logo_email.gif', array('_area' => 'frontend')), 30);
     $this->addNewLine(4);
     $helloStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $helloStyle->setFont($fontH, 14);
     $color = Zend_Pdf_Color_Html::color('black');
     $helloStyle->setFillColor($color);
     $this->addText('Hello, ' . $data->getData('email-to') . "!", $helloStyle);
     $this->addNewLine(3);
     $this->addText('You have received a ' . $data->getAmount() . ' Gift Card from ', $style);
     $fromStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
     $fromStyle->setFont($fontH, 10);
     $this->addText($data->getData('email-from'), $fromStyle);
     $this->addText("! ", $style);
     $store = Mage::getModel('core/store')->load($data->getStoreId());
     $this->addText('This card may be redeemed on ' . $store->getFrontendName() . ' website. Happy shopping!', $style);
     $this->addNewLine(1, $style->getFontSize());
     $this->addImage($data->getPicture(), 400, $this->getLineLimit());
     $this->addNewLine(5);
     $subStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $subStyle->setFont($fontH, 13);
     $color = Zend_Pdf_Color_Html::color('gray');
     $subStyle->setFillColor($color);
     $this->addText('to: ' . $data->getData('email-to'), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('from: ' . $data->getData('email-from'), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText("message: " . $data->getData('email-message'), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('gift card value:' . $data->getAmount(), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('gift card claim code:' . $data->getCode(), $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addNewLine(5);
     $subStyle = new Zend_Pdf_Style();
     $fontH = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
     $subStyle->setFont($fontH, 9);
     $color = Zend_Pdf_Color_Html::color('black');
     $subStyle->setFillColor($color);
     $this->addText('To redeem and use you gift card: ', $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('    1. Create an account and login into ' . $store->getUrl() . ".", $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('    2. Redeem the card in My Gift Cards page of My Account section.', $subStyle);
     $this->addNewLine(1, $subStyle->getFontSize());
     $this->addText('    3. Alternatively, you can redeem the card on My Cart page before proceeding to checkout.', $subStyle);
     $this->addNewLine(2, $subStyle->getFontSize());
     $this->addText('If you have any questions please contact us at ' . Mage::getStoreConfig('trans_email/ident_support/email'), $subStyle);
     $phone = $data->getData('store-phone');
     if (isset($phone)) {
         $this->addText(' or call us at ' . $phone . " Monday - Friday, 8am - 5pm PST.", $subStyle);
     }
     $this->_currentPdf = new Zend_Pdf();
     $this->_currentPdf->pages[] = $this->_currentPage;
     $this->clearTempFiles();
     return $this->_currentPdf->render();
 }
Exemplo n.º 12
0
 $image = Zend_Pdf_Image::imageWithPath('./public/image/logo1.png');
 // write image to page
 $page1->drawImage($image, 240, 668, 360, 790);
 $diaChi = "Dia Chi: 268 Lý Thường Kiệt, Phường 9, Quận 10, TP. Hồ Chí Minh";
 $sdt = "SDT: 08 3568256";
 $page1->setStyle($style)->drawText($diaChi, 50, 650, $charEncoding = 'UTF-8');
 $page1->setStyle($style)->drawText($sdt, 50, 630, $charEncoding = 'UTF-8');
 $title = "THONG TIN DON XUAT";
 // Create new Style
 $styleTitle = new Zend_Pdf_Style();
 $styleTitle->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
 $styleTitle->setLineColor(new Zend_Pdf_Color_GrayScale(0.2));
 $styleTitle->setLineWidth(3);
 $styleTitle->setLineDashingPattern(array(3, 2, 3, 4), 1.6);
 $fontTitle = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER);
 $styleTitle->setFont($fontTitle, 30);
 $page1->setStyle($styleTitle)->drawText($title, 130, 600, $charEncoding = 'UTF-8');
 // add footer text
 $page1->drawLine(80, 25, $page2->getWidth() - 10, 25);
 $page1->drawImage($image, 20, 10, $image->getPixelWidth(), $image->getPixelHeight());
 $page1->setStyle($style)->drawText('Copyright @HCMUT. All rights reserved.', 200, 10);
 $page1->drawLine(40, 580, $page2->getWidth() - 10, 580);
 // 25 --> 580
 // Thông tin khach hang, Get thông tin theo mã khách hàng. Đơn xuất->Mã Đơn Hàng-> Mã Khách hàng
 $postMaKH = 1234;
 // Dữ liệu giả.
 $modelKhachhang = new Model_Khachhang();
 $thongtinkh = $modelKhachhang->getByMakh($postMaKH);
 foreach ($thongtinkh as $data) {
     $tenkh = $data['TenKhachHang'];
     $diachikh = $data['DiaChi'];
 public function downloadAction()
 {
     if ($this->_loadValidVoucher()) {
         $voucherCode = $this->getRequest()->getParam('code');
         $text = Mage::helper('voucher');
         $_product = Mage::registry('current_product');
         $pdf = new Zend_Pdf();
         $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER);
         $pageHeight = $page->getHeight();
         $pageWidth = $page->getWidth();
         //$page->rotate(($pageWidth/2), ($pageHeight/2), 1);
         $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
         $logoImage = Zend_Pdf_Image::imageWithPath(Mage::getDesign()->getSkinBaseDir() . '/images/logo_small_en.jpg');
         //$footerImage = Zend_Pdf_Image::imageWithPath(Mage::getDesign()->getSkinBaseDir() . '/images/voucher_footer_en.png'); //VD
         $productImage = Zend_Pdf_Image::imageWithPath(Mage::getBaseDir() . '/media/catalog/product' . $_product->getVoucherImage());
         //$footerImageHeight = $footerImage->getPixelHeight();  //VD
         //$footerImageWidth = $footerImage->getPixelWidth();  //VD
         $logoImageHeight = 75;
         //VDEdit
         $logoImageWidth = 250;
         //VDEdit
         $tableWidth = 568;
         $startPoint = ($pageWidth - $tableWidth) / 2;
         $endPoint = $startPoint + $tableWidth;
         $botPoint = 10;
         $topPoint = $pageHeight - 30;
         $page->setLineWidth('0.3')->setLineDashingPattern(array(3, 3, 3, 3))->drawLine($startPoint, $topPoint, $startPoint, $botPoint)->drawLine($endPoint, $topPoint, $endPoint, $botPoint)->drawLine($startPoint, $topPoint, $endPoint, $topPoint)->drawLine($startPoint, $botPoint, $endPoint, $botPoint)->drawLine($startPoint, $pageHeight - $logoImageHeight - 235, $endPoint, $pageHeight - $logoImageHeight - 235)->drawLine($startPoint, $pageHeight - $logoImageHeight - 235 - 325, $endPoint, $pageHeight - $logoImageHeight - 235 - 325);
         $page->setFillColor(Zend_Pdf_Color_Html::color('#16599D'))->drawRectangle($startPoint + 2, $topPoint - $logoImageHeight - 2, $endPoint, $topPoint);
         $page->drawImage($logoImage, $startPoint, $topPoint - $logoImageHeight - 1, $startPoint + $logoImageWidth, $topPoint);
         //$page->drawImage($footerImage, $startPoint + 2, $botPoint, $startPoint + $footerImageWidth - 20, $botPoint + $footerImageHeight);
         $page->drawImage($productImage, $startPoint + 7, $topPoint - 55 - $productImage->getPixelHeight(), $startPoint + 7 + 246, $topPoint - 55 - $productImage->getPixelHeight() + 165);
         $page->setFillColor(Zend_Pdf_Color_Html::color('#FFFFFF'))->setLineDashingPattern(array(1, 0, 1, 0))->drawRectangle($endPoint - 205, $topPoint - 10, $endPoint - 15, $topPoint + 10)->setLineDashingPattern(array(0, 1000, 0, 1000))->setFillColor(Zend_Pdf_Color_Html::color('#EDF4FA'))->drawRectangle($startPoint + 0.3, $pageHeight - $logoImageHeight - 235, $endPoint, $pageHeight - $logoImageHeight - 235 - 325);
         $style = new Zend_Pdf_Style();
         $style->setFont($font, 15);
         $page->setFont($font, 12)->setFillColor(Zend_Pdf_Color_Html::color('#000000'))->drawText($text->__('Voucher Code: ' . $voucherCode), $endPoint - 193, $topPoint - 4)->setFont($font, 15);
         $lines = explode("\n", $this->getWrappedText($text->__('Voucher for ') . $_product->getName(), $style, 270));
         //var_dump($lines);
         foreach ($lines as $k => $line) {
             $page->drawText($line, $startPoint + $productImage->getPixelWidth() + 20, $topPoint - 70 - $k * 20);
         }
         //
         $pdf->pages[0] = $page;
         $pdf->save(Mage::getBaseDir() . '/media/vouchers/' . $voucherCode . '.pdf');
         $this->getResponse()->clearHeaders()->setHeader('content-type:', 'Application/pdf')->setHeader('Content-Type', 'application/force-download')->setHeader('Content-Disposition', 'attachment; filename="' . $voucherCode . '.pdf"')->setBody($pdf->render());
     }
 }
Exemplo n.º 14
0
 public function getPdf($orders = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     if ($this->pdf == null) {
         $this->pdf = new Zend_Pdf();
     } else {
         $this->firstPageIndex = count($this->pdf->pages);
     }
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     foreach ($orders as $order) {
         //cree la nouvelle page
         $titre = mage::helper('purchase')->__('Purchase Order');
         $settings = array();
         $settings['title'] = $titre;
         $settings['store_id'] = 0;
         $page = $this->NewPage($settings);
         //cartouche
         //$txt_date = "Date :  ".mage::helper('core')->formatDate($order->getCreatedAt(), 'long');
         $txt_date = "Date :  " . date('d/m/Y', strtotime($order->getpo_date()));
         $txt_order = "PO# : " . $order->getpo_order_id();
         $adresse_fournisseur = $order->getSupplier()->getAddressAsText();
         if ($order->getShipTo() != '') {
             $adresse_client = $order->getShipTo();
         } else {
             $adresse_client = Mage::getStoreConfig('sales/identity/address');
         }
         $this->AddAddressesBlock($page, $adresse_fournisseur, $adresse_client, $txt_date, $txt_order);
         //affiche l'entete du tableau
         $this->drawTableHeader($page);
         $this->y -= 10;
         //Affiche les lignes produit
         foreach ($order->getProducts() as $item) {
             $productId = Mage::getModel('catalog/product')->getIdBySku($item->getSku());
             $product = Mage::getModel('catalog/product')->load($productId);
             //Pour les produits "standards"
             $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
             $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
             //this is our real SKU
             $caption = $this->WrapTextToWidth($page, $item->getSku(), 55);
             $offset = $this->DrawMultilineText($page, $caption, 15, $this->y, 10, 0.2, 11);
             //display SKU or picture
             if ($this->_showPictures == false) {
                 $caption = $this->WrapTextToWidth($page, $item->getpop_supplier_ref(), 80);
                 $offset = $this->DrawMultilineText($page, $caption, 80, $this->y, 10, 0.2, 11);
             } else {
                 $product = mage::getModel('catalog/product')->load($item->getpop_product_id());
                 if ($product->getId()) {
                     $productImagePath = Mage::getBaseDir() . '/media/catalog/product' . $product->getsmall_image();
                     if (is_file($productImagePath)) {
                         try {
                             $image = Zend_Pdf_Image::imageWithPath($productImagePath);
                             $page->drawImage($image, 10, $this->y - $this->_pictureSize + 20, 5 + $this->_pictureSize, $this->y + 10);
                         } catch (Exception $ex) {
                         }
                     }
                 }
             }
             $caption = $this->WrapTextToWidth($page, $item->getpop_product_name(), 135);
             $offset = $this->DrawMultilineText($page, $caption, 160, $this->y, 10, 0.2, 11);
             //if ($order->getpo_status() != MDN_Purchase_Model_Order::STATUS_INQUIRY )
             $this->drawTextInBlock($page, $product->getData('hts'), 300, $this->y, 60, 20, 'r');
             $this->drawTextInBlock($page, $order->getCurrency()->formatTxt($item->getpop_price_ht()), 415, $this->y, 60, 20, 'r');
             $this->drawTextInBlock($page, (int) $item->getpop_qty(), 380, $this->y, 40, 20, 'c');
             //if ($order->getpo_status() != MDN_Purchase_Model_Order::STATUS_INQUIRY )
             //{
             //$this->drawTextInBlock($page, $order->getCurrency()->formatTxt($item->getpop_eco_tax()), 365, $this->y, 40, 20, 'c');
             //$this->drawTextInBlock($page, number_format($item->getpop_tax_rate(), 2).'%', 410, $this->y, 40, 20, 'c');
             $this->drawTextInBlock($page, $order->getCurrency()->formatTxt($item->getRowTotal()), 495, $this->y, 60, 20, 'r');
             //$this->drawTextInBlock($page, $order->getCurrency()->formatTxt($item->getRowTotalWithTaxes($order->getpo_tax_rate())), 520, $this->y, 60, 20, 'r');
             //}	        	getProduct()->getsku()
             if ($this->_showPictures) {
                 $this->y -= $this->_pictureSize;
             } else {
                 $this->y -= $this->_ITEM_HEIGHT;
             }
             //si on a plus la place de rajouter le footer, on change de page
             if ($this->y < $this->_BLOC_FOOTER_HAUTEUR + 40) {
                 $this->drawFooter($page);
                 $page = $this->NewPage($settings);
                 $this->drawTableHeader($page);
             }
             if ($product->getData('upc') != '') {
                 $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
                 $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_OBLIQUE), 8);
                 $this->drawTextInBlock($page, 'UPC: ' . $product->getData('upc'), 15, $this->y + 10, 60, 20, 'l');
                 $this->y -= 10;
                 $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
                 $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
             }
         }
         //rajoute les frais d'expédition
         if ($order->getpo_status() != MDN_Purchase_Model_Order::STATUS_INQUIRY) {
             $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
             $this->DrawMultilineText($page, mage::helper('purchase')->__('Shipping costs'), 90, $this->y, 10, 0.2, 11);
             //$this->drawTextInBlock($page, number_format($order->getpo_tax_rate(), 2).'%', 410, $this->y, 40, 20, 'c');
             $this->drawTextInBlock($page, $order->getCurrency()->formatTxt($order->getShippingAmountHt()), 450, $this->y, 60, 20, 'r');
             $this->drawTextInBlock($page, $order->getCurrency()->formatTxt($order->getShippingAmountTtc()), 520, $this->y, 60, 20, 'r');
             //rajoute les droits de douane
             //$this->y -= $this->_ITEM_HEIGHT;
             //$style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
             //$this->DrawMultilineText($page, mage::helper('purchase')->__('Zoll costs'), 90, $this->y, 10, 0.2, 11);
             //$this->drawTextInBlock($page, number_format($order->getpo_tax_rate(), 2).'%', 410, $this->y, 40, 20, 'c');
             //$this->drawTextInBlock($page, $order->getCurrency()->formatTxt($order->getZollAmountHt()), 450, $this->y, 60, 20, 'r');
             //$this->drawTextInBlock($page, $order->getCurrency()->formatTxt($order->getZollAmountTtc()), 520, $this->y, 60, 20, 'r');
         }
         //si on a plus la place de rajouter le footer, on change de page
         if ($this->y < 150) {
             $this->drawFooter($page);
             $page = $this->NewPage($settings);
             $this->drawTableHeader($page);
         }
         //barre grise début totaux
         $this->y -= 10;
         $page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
         //barre verticale de séparation des totaux
         $VerticalLineHeight = 80;
         $page->drawLine($this->_PAGE_WIDTH / 2, $this->y, $this->_PAGE_WIDTH / 2, $this->y - $VerticalLineHeight);
         //rajoute les libellés & les totaux
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 14);
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
         $this->y -= 20;
         //Zone commentaires
         $comments = Mage::getStoreConfig('purchase/general/pdf_comment');
         if ($comments != '' && $comments != null) {
             $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.3));
             $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12);
             $page->drawText(mage::helper('purchase')->__('Bill To:'), 15, $this->y, 'UTF-8');
             //$offset = $this->DrawMultilineText($page, $com, 15, $this->y - 15, 10, 0.3, 11);
             //$this->drawTextInBlock($page, $com, 15, $this->y - 15, 200, 200, 'l');
             $page->setFillColor(new Zend_Pdf_Color_GrayScale(0.3));
             $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
             $comments = $this->WrapTextToWidth($page, $comments, $this->_PAGE_WIDTH / 2);
             $this->DrawMultilineText($page, $comments, 15, $this->y - 15, 10, 0.2, 11);
         }
         //if ($order->getpo_status() != MDN_Purchase_Model_Order::STATUS_INQUIRY )
         //{
         $page->drawText(mage::helper('purchase')->__('Sub Total.'), $this->_PAGE_WIDTH / 2 + 10, $this->y, 'UTF-8');
         $this->drawTextInBlock($page, $order->getCurrency()->formatTxt($order->getTotalWithOutDuty()), $this->_PAGE_WIDTH / 2, $this->y, $this->_PAGE_WIDTH / 2 - 30, 40, 'r');
         $this->y -= 20;
         $page->drawText('Estimated Duty.', $this->_PAGE_WIDTH / 2 + 10, $this->y, 'UTF-8');
         $this->drawTextInBlock($page, $order->getCurrency()->formatTxt($order->getTaxAmount()), $this->_PAGE_WIDTH / 2, $this->y, $this->_PAGE_WIDTH / 2 - 30, 40, 'r');
         $this->y -= 20;
         $page->drawText('Grand Total.', $this->_PAGE_WIDTH / 2 + 10, $this->y, 'UTF-8');
         $this->drawTextInBlock($page, $order->getCurrency()->formatTxt($order->getTotalTtc()), $this->_PAGE_WIDTH / 2, $this->y, $this->_PAGE_WIDTH / 2 - 30, 40, 'r');
         //}
         //barre grise fin totaux
         $this->y -= 20;
         $page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
         //Rajoute le réglement et le transporteur
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
         $this->y -= 20;
         $page->drawText(mage::helper('purchase')->__('Billing Method : ') . $order->getpo_payment_type(), 15, $this->y, 'UTF-8');
         $this->y -= 20;
         $page->drawText(mage::helper('purchase')->__('Carrier : ') . $order->getpo_carrier(), 15, $this->y, 'UTF-8');
         $this->y -= 20;
         $page->drawText('Shipping Method: ' . $order->getShipSpeed(), 15, $this->y, 'UTF-8');
         //ligne de séparation
         $this->y -= 20;
         $page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
         //Zone acceptation de la commande
         $this->y -= 20;
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
         $page->drawText(mage::helper('purchase')->__('Comments : '), 15, $this->y, 'UTF-8');
         $this->y -= 20;
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
         $txt = $order->getpo_comments();
         $txt = $this->WrapTextToWidth($page, $txt, $this->_PAGE_WIDTH - 100);
         $this->DrawMultilineText($page, $txt, 15, $this->y, 10, 0.2, 11);
         //dessine le pied de page
         $this->drawFooter($page);
     }
     //rajoute la pagination
     $this->AddPagination($this->pdf);
     $this->_afterGetPdf();
     return $this->pdf;
 }
Exemplo n.º 15
0
 public function remittanceInvoice($batch_id = 27, $shop_date_remittance = null)
 {
     $user = $this;
     $page_count = 0;
     $footer_added = 0;
     $pdf = new Zend_Pdf();
     $pdf->pages[] = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     $page = $pdf->pages[$page_count];
     $style = new Zend_Pdf_Style();
     $style->setLineColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
     $style->setFont($font, 16);
     $page->setStyle($style);
     $page_height = $page->getHeight();
     $page->drawText('RECIPIENT CREATED TAX INVOICE', 150, $page_height - 80);
     $style->setFont($font, 12);
     $page->setStyle($style);
     $company = trim($user->company) != '' ? $user->company : $user->first_name . ' ' . $user->last_name;
     $address1 = !empty($this->delivery_address1) ? $this->delivery_address1 . ' ' : null;
     $address1 .= !empty($this->delivery_address2) ? $this->delivery_address2 . ' ' : null;
     $address1 .= !empty($this->delivery_city) ? $this->delivery_city . ' ' : null;
     $address2 = !empty($this->delivery_state) ? $this->delivery_state . ', ' : null;
     $address2 .= !empty($this->delivery_postcode) ? $this->delivery_postcode : null;
     $page->drawText($company, 50, $page->getHeight() - 120);
     $page->drawText($address1, 50, $page->getHeight() - 133);
     $page->drawText($address2, 50, $page->getHeight() - 147);
     $page->drawText('ABN # ' . $this->abn, 50, $page->getHeight() - 160);
     $remittanceDate = !empty($shop_date_remittance) ? date('d/m/Y') : date('d/m/Y');
     $invoice_number = $this->id . '-' . $batch_id;
     $page->drawText('Remittance Date: ' . $remittanceDate, 400, $page->getHeight() - 120);
     $page->drawText('Invoice number: ' . $invoice_number, 400, $page->getHeight() - 133);
     $style->setFont($font, 10);
     $page->setStyle($style);
     $page->drawText('Note: only items that were sold with GST applicable will appear on this invoice', 100, $page->getHeight() - 188);
     $head_row_height = 20;
     $row_height = 20;
     $line_height_start = $page_height - 200;
     $total_data_row = 30;
     $page_break_row = 25;
     $textline_height = 12;
     $spModel = Base::getModel('Shop_Products');
     $select = $spModel->select()->setIntegrityCheck(false)->from(array('sp' => 'shop_products'));
     //join with common_items
     $select->join(array('ci' => 'common_items'), 'sp.client_product_id = ci.client_product_id', array('sum(ci.copies) as copies, sum(ci.copies*ci.shop_markup) as shop_markup,  ci.registered_gst as gst', 'ci.registered_gst'));
     $select->where('ci.remittance_batch_id = ?', $batch_id);
     if (!empty($shop_date_remittance)) {
         $select->where('ci.shop_date_remittance = ?', $shop_date_remittance);
     }
     $select->where('sp.common_user_id = ?', $user->id);
     $select->where('ci.registered_gst = 1');
     $select->group(array('sp.common_user_id', 'gst'));
     $shop_markup_inc_gst = $shop_markup_exc_gst = '';
     //Zend_Debug::dump((string)$select); die();
     $rows = $spModel->fetchAll($select);
     $total_data_row = $rows->count();
     $i = 1;
     $j = 1;
     $total_copies = 0;
     $total_Ex_GST = $total_Inc_GST = 0.0;
     foreach ($rows as $row) {
         if ($i == 1) {
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
             $style->setFont($font, 10);
             $page->setStyle($style);
             $page->drawLine(60, $line_height_start, 540, $line_height_start)->drawLine(60, $line_height_start, 60, $line_height_start - $head_row_height)->drawLine(300, $line_height_start, 300, $line_height_start - $head_row_height)->drawLine(360, $line_height_start, 360, $line_height_start - $head_row_height)->drawLine(450, $line_height_start, 450, $line_height_start - $head_row_height)->drawLine(60, $line_height_start - $head_row_height, 540, $line_height_start - $head_row_height)->drawLine(540, $line_height_start, 540, $line_height_start - $head_row_height)->drawText('Description', 68, $line_height_start - $textline_height)->drawText('Copies', 308, $line_height_start - $textline_height)->drawText('Ex-GST Amount', 368, $line_height_start - $textline_height)->drawText('Inc-GST Amount', 458, $line_height_start - $textline_height);
             // Table Headers
             $line_height_start = $line_height_start - $head_row_height;
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
             $style->setFont($font, 10);
             $page->setStyle($style);
         }
         $shop_markup = sprintf("%01.2f", $row->shop_markup);
         $shop_markup_len = strlen($shop_markup);
         $num_pad = 5 * ($shop_markup_len - 4);
         $page->drawLine(60, $line_height_start, 540, $line_height_start)->drawLine(60, $line_height_start, 60, $line_height_start - $row_height)->drawLine(300, $line_height_start, 300, $line_height_start - $row_height)->drawLine(360, $line_height_start, 360, $line_height_start - $row_height)->drawLine(450, $line_height_start, 450, $line_height_start - $row_height)->drawLine(60, $line_height_start - $row_height, 540, $line_height_start - $row_height)->drawLine(540, $line_height_start, 540, $line_height_start - $row_height)->drawText($row->title, 68, $line_height_start - $textline_height)->drawText($row->copies, 330, $line_height_start - $textline_height)->drawText($row->gst == 1 ? sprintf("%01.2f", $shop_markup - $shop_markup / 11) : sprintf("%01.2f", $shop_markup), 425 - $num_pad, $line_height_start - $textline_height)->drawText(sprintf("%01.2f", $shop_markup), 515 - $num_pad, $line_height_start - $textline_height);
         // Table Headers
         $line_height_start = $line_height_start - $row_height;
         $total_copies += $row->copies;
         $total_Inc_GST += $shop_markup;
         if ($row->gst == 1) {
             $total_Ex_GST += $shop_markup - $shop_markup / 11;
         } else {
             $total_Ex_GST += $shop_markup;
         }
         $footer_added = 0;
         if ($j == $total_data_row) {
             $total_Ex_GST = sprintf("%01.2f", $total_Ex_GST);
             $total_Inc_GST = sprintf("%01.2f", $total_Inc_GST);
             $len = strlen($total_Ex_GST);
             $ex_gst_num_pad = 5 * ($len - 4);
             $len = strlen($total_Inc_GST);
             $inc_gst_num_pad = 5 * ($len - 4);
             $len = strlen($total_copies);
             $copies_num_pad = 5 * ($len - 1);
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
             $style->setFont($font, 10);
             $page->setStyle($style);
             $page->drawLine(60, $line_height_start, 540, $line_height_start)->drawLine(60, $line_height_start, 60, $line_height_start - $head_row_height)->drawLine(300, $line_height_start, 300, $line_height_start - $head_row_height)->drawLine(360, $line_height_start, 360, $line_height_start - $head_row_height)->drawLine(450, $line_height_start, 450, $line_height_start - $head_row_height)->drawLine(60, $line_height_start - $head_row_height, 540, $line_height_start - $head_row_height)->drawLine(540, $line_height_start, 540, $line_height_start - $head_row_height)->drawText('Total', 68, $line_height_start - $textline_height)->drawText($total_copies, 330 - $copies_num_pad, $line_height_start - $textline_height)->drawText($total_Ex_GST, 425 - $ex_gst_num_pad, $line_height_start - $textline_height)->drawText($total_Inc_GST, 515 - $inc_gst_num_pad, $line_height_start - $textline_height);
             // Table Headers
             $line_height_start = $line_height_start - $head_row_height;
             $footer_added = 1;
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
             $style->setFont($font, 10);
             $page->setStyle($style);
             $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOP/htdocs/images/logo.jpg');
             $page->drawImage($image, 65, 40, 250, 80);
             $page->drawText('PO Box 140, Strawberry Hills NSW 2012', 68, 30);
             $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOS/htdocs/images/logo.jpg');
             $page->drawImage($image, 400, 40, 550, 80);
         }
         if ($i == $page_break_row) {
             if ($footer_added == 0) {
                 $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOP/htdocs/images/logo.jpg');
                 $page->drawImage($image, 65, 40, 250, 80);
                 $page->drawText('PO Box 140, Strawberry Hills NSW 2012', 68, 30);
                 $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOS/htdocs/images/logo.jpg');
                 $page->drawImage($image, 400, 40, 550, 80);
                 $page_count++;
                 $pdf->pages[$page_count] = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
                 $page = $pdf->pages[$page_count];
                 $style = new Zend_Pdf_Style();
                 $style->setLineColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
                 $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
                 $style->setFont($font, 10);
                 $page->setStyle($style);
                 $line_height_start = $page_height - 80;
             }
             $page_break_row = 30;
             $i = 1;
         } else {
             $i++;
         }
         $j++;
     }
     if ($footer_added == 0) {
         $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOP/htdocs/images/logo.jpg');
         $page->drawImage($image, 65, 40, 250, 80);
         $page->drawText('PO Box 140, Strawberry Hills NSW 2012', 68, 30);
         $image = Zend_Pdf_Image::imageWithPath(APPLICATION_PATH . '/../sites/MOS/htdocs/images/logo.jpg');
         $page->drawImage($image, 400, 40, 550, 80);
     }
     if ($total_data_row > 0) {
         $pdf->save(APPLICATION_PATH . '/../tmp/remittance_invoice/' . $invoice_number . '.pdf');
     } else {
         return false;
     }
 }
Exemplo n.º 16
0
 public function __construct($param1, $param2 = null, $param3 = null)
 {
     parent::__construct($param1, $param2, $param3);
     $style = new Zend_Pdf_Style();
     $style->setLineColor(new Zend_Pdf_Color_Html("#000000"));
     $style->setFillColor(new Zend_Pdf_Color_Html("#000000"));
     $style->setLineWidth(0.5);
     $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER);
     $style->setFont($font, 10);
     $style->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID);
     $this->_defaultStyle = $style;
     $this->setStyle($style);
 }
Exemplo n.º 17
0
        // Throw an exception if it's not the "Can't open file" exception
        throw $e;
    }
}

//------------------------------------------------------------------------------------
// 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
Exemplo n.º 18
0
 public function getPdf($invoices = array())
 {
     $pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     foreach ($invoices as $invoice) {
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
         $pdf->pages[] = $page;
         $order = $invoice->getOrder();
         /* Add image */
         $this->insertLogo($page);
         /* Add address */
         $this->insertAddress($page);
         /* Add head */
         $this->insertOrder($page, $order);
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 7);
         $page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35, 780);
         /* Add table */
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
         $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
         $page->setLineWidth(0.5);
         $page->drawRectangle(25, $this->y, 570, $this->y - 15);
         $this->y -= 10;
         /* Add table head */
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
         $page->drawText(Mage::helper('sales')->__('QTY'), 35, $this->y);
         $page->drawText(Mage::helper('sales')->__('Products'), 60, $this->y);
         $page->drawText(Mage::helper('sales')->__('SKU'), 380, $this->y);
         $page->drawText(Mage::helper('sales')->__('Total(inc)'), 530, $this->y);
         $this->y -= 15;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         /* Add body */
         foreach ($invoice->getAllItems() as $item) {
             $shift = 10;
             if ($this->y < 15) {
                 /* Add new table head */
                 $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
                 $pdf->pages[] = $page;
                 $this->y = 800;
                 $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 7);
                 $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
                 $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
                 $page->setLineWidth(0.5);
                 $page->drawRectangle(25, $this->y, 570, $this->y - 15);
                 $this->y -= 10;
                 $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
                 $page->drawText(Mage::helper('sales')->__('QTY'), 35, $this->y);
                 $page->drawText(Mage::helper('sales')->__('Products'), 60, $this->y);
                 $page->drawText(Mage::helper('sales')->__('SKU'), 380, $this->y);
                 $page->drawText(Mage::helper('sales')->__('Price'), 530, $this->y);
                 $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                 $this->y -= 20;
             }
             /* Add products */
             $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 7);
             $page->drawText($item->getQty() * 1, 35, $this->y);
             $page->drawText($item->getName(), 60, $this->y);
             foreach (explode('</li>', $item->getDescription()) as $description) {
                 $page->drawText(strip_tags($description), 65, $this->y - $shift);
                 $shift += 10;
             }
             $page->drawText($item->getSku(), 380, $this->y);
             $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
             $row_total = $order->formatPriceTxt($item->getRowTotal() + $item->getTaxAmount() - $item->getDiscountAmount());
             $page->drawText($row_total, 565 - $this->widthForStringUsingFontSize($row_total, $font, 7), $this->y);
             $this->y -= $shift;
         }
         /* Add totals */
         $this->insertTotals($page, $invoice);
     }
     return $pdf;
 }
Exemplo n.º 19
0
 public function getPdf($shipments = array())
 {
     $pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
     foreach ($shipments as $shipment) {
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
         $pdf->pages[] = $page;
         $order = $shipment->getOrder();
         /* Add image */
         $this->insertLogo($page);
         /* Add address */
         $this->insertAddress($page);
         /* Add head */
         $this->insertOrder($page, $order);
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
         $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 7);
         $page->drawText(Mage::helper('sales')->__('Packingslip # ') . $shipment->getIncrementId(), 35, 780);
         /* Add table */
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
         $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
         $page->setLineWidth(0.5);
         /* Add table head */
         $page->drawRectangle(25, $this->y, 570, $this->y - 15);
         $this->y -= 10;
         $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
         $page->drawText(Mage::helper('sales')->__('QTY'), 35, $this->y);
         $page->drawText(Mage::helper('sales')->__('Products'), 60, $this->y);
         $page->drawText(Mage::helper('sales')->__('SKU'), 470, $this->y);
         $this->y -= 15;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         /* Add body */
         foreach ($shipment->getAllItems() as $item) {
             $shift = 10;
             if ($this->y < 15) {
                 /* Add new table head */
                 $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
                 $pdf->pages[] = $page;
                 $this->y = 800;
                 $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 7);
                 $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
                 $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
                 $page->setLineWidth(0.5);
                 $page->drawRectangle(25, $this->y, 570, $this->y - 15);
                 $this->y -= 10;
                 $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
                 $page->drawText(Mage::helper('sales')->__('QTY'), 35, $this->y);
                 $page->drawText(Mage::helper('sales')->__('Products'), 60, $this->y);
                 $page->drawText(Mage::helper('sales')->__('SKU'), 470, $this->y);
                 $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                 $this->y -= 20;
             }
             /* Add products */
             $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 7);
             $page->drawText($item->getQty() * 1, 35, $this->y);
             $page->drawText($item->getName(), 60, $this->y);
             $page->drawText($item->getName(), 60, $this->y);
             foreach (explode('</li>', $item->getDescription()) as $description) {
                 $page->drawText(strip_tags($description), 65, $this->y - $shift);
                 $shift += 10;
             }
             $page->drawText($item->getSku(), 470, $this->y);
             $this->y -= $shift;
         }
     }
     return $pdf;
 }
Exemplo n.º 20
0
 /**
  * Draw table or part of table by coordinates with or without header
  *
  * @param array[][] $table Table values
  * @param int $x x coordinate
  * @param int $y y coordinate
  * @param int $width Table width
  * @param int $max_y Minimal y coordinate
  * @param array[] $header Table header
  * @param int $start_row start row of table
  *
  * @return int End row
  *
  * @api
  */
 function drawTable($table, $x, $y, $width, $max_y = 0, $header = NULL, $start_row = 0, $params = false, $note = '')
 {
     if (!$table) {
         return NULL;
     }
     if ($start_row > count($table) - 1) {
         if ($this->currentPosition > $y - $this->MARGIN['bottom']) {
             $this->currentPosition = $y - $this->MARGIN['bottom'];
         }
         return NULL;
     }
     $max_widths = $this->getTableColumnsMaxWidths($table, $params);
     $avg_widths = $this->getTableColumnsAverageWidths($table, $params);
     //	parent::drawText(implode(',',$max_widths), $this -> MARGIN['left'], $this -> MARGIN['bottom'], 'UTF-8');
     //вычисляем ширину столбцов, в зависимости от того, какую таблицу рисуем выбираем нужную формулу
     if ($params) {
         $awidth = array_sum($max_widths) - 0;
     } else {
         $awidth = array_sum($avg_widths) - $avg_widths[0] - 5;
         $widths = array($max_widths[0]);
     }
     // Подгоняем ширину под заданную, через процентные соотношения
     foreach ($avg_widths as $i => $a_w) {
         if ($params) {
             $widths[] = $a_w / $awidth * $width;
         } elseif ($i != 0) {
             $widths[] = $a_w / $awidth * ($width - $widths[0] - 10);
         }
     }
     // запомним наш $x  и текущий $y
     $coords = array($x, $y);
     // write header ( if exists )
     if ($header) {
         //создаем сностки для таблици с параметрами. В зависимости от количества столбцов и длинны названия параметра, заменяем его и записываем в сноски
         $snoski = '';
         $s_number = 1;
         $widthSnoski = $width;
         $this->pageFormat == 'A4' ? $countChar = 30 : ($countChar = 10);
         foreach ($header as $i => $column) {
             if (count($header) > 7 && strlen($column) >= $countChar && $i != 0 || $column == 'Типоразмер') {
                 if ($widthSnoski < $this->widthForStringUsingFontsize($s_number . '* - ' . $column . '; ', Model_Static_Fonts::get("Arial Narrow"), $this->fontSizeFormatSnoski) + $this->widthForStringUsingFontsize($snoski, Model_Static_Fonts::get("Arial Narrow"), $this->fontSizeFormatSnoski)) {
                     $snoski .= chr('0x0D') . chr('0x0A');
                     $widthSnoski *= 2;
                 }
                 $snoski .= $s_number . '* - ' . $column . '; ';
                 $header[$i] = $s_number . '*';
                 $s_number++;
             } elseif ($this->pageFormat == 'A5') {
                 $header[$i] = str_replace('(', chr('0x0D') . chr('0x0A') . '(', $column);
             }
         }
         $snoski .= ' ' . $note;
         $this->saveGS();
         $style = new Zend_Pdf_Style();
         $style->setFillColor(new Zend_Pdf_Color_Html("white"));
         $style->setFont(Model_Static_Fonts::get("Arial Narrow"), $this->fontSizeFormatHeader);
         // Bold
         $this->setStyle($style);
         // calculate height of header
         $height = 0;
         foreach ($header as $i => $column) {
             $style->setLineWidth($widths[$i]);
             $height = max($height, $this->getTextBlockHeight(trim($column), $style, 0, true));
         }
         // if we can't write 2 line - exit
         if ($y - $height - $max_y < 16) {
             $this->restoreGS();
             return 0;
         }
         // else - draw header background
         $this->drawHorizontalLine($coords[0] + 5, $coords[0] + $width, $this->pageFormat == 'A4' ? $y - $height / 2 + 5.5 : $y - $height / 2 + 3.5, $height, new Zend_Pdf_Color_Html("#0095da"));
         // here - write header
         //
         foreach ($header as $i => $col) {
             $style->setLineWidth($widths[$i]);
             $width_text = $this->widthForStringUsingFontsize($col, $style->getFont(), $style->getFontSize());
             if ($widths[$i] > $width_text && $i != 0) {
                 $iLeft = $x + ($widths[$i] - $width_text) / 2;
             } else {
                 $iLeft = $x + 8;
             }
             $y = min($y, $this->drawTextBlock(str_replace(array(''), array(''), trim($col)), $iLeft + 1 * ($i == 0), $coords[1] - 3, $style, 0, true));
             $x += $widths[$i];
         }
         $this->restoreGS();
     }
     // make offset(3)
     if ($this->pageFormat == 'A4') {
         $y -= 2;
     } elseif ($this->pageFormat == 'A5') {
         $y -= 0;
     }
     // write table data
     $coords[0] += 5;
     $width -= 5;
     for ($c_row = $start_row; $c_row < count($table); $c_row++) {
         $rowset = $table[$c_row];
         $x = $coords[0];
         $line_y = $y;
         // for table with headers odd lines have bg
         if ($c_row % 2 != 0 && $header) {
             $style = new Zend_Pdf_Style();
             $style->setLineWidth($widths[$i] + 10);
             $style->setFont(Model_Static_Fonts::get("Arial Narrow" . ($i == 0 && !$header ? ' Bold' : '')), $this->fontSizeFormat);
             $height = 0;
             foreach ($rowset as $i => $col) {
                 $style->setLineWidth($widths[$i]);
                 $height = max($height, $this->getTextBlockHeight($col, $style));
             }
             if ($this->pageFormat == 'A4') {
                 $this->drawHorizontalLine($x, $x + $width, $y + (3 - intval(($height - 2) / 6 - 1.5) * 2), $height - 4, new Zend_Pdf_Color_Html("#e7e7e7"));
             } elseif ($this->pageFormat == 'A5') {
                 $this->drawHorizontalLine($x, $x + $width, $y + (2 - intval(($height - 2) / 6 - 1) * 2), $height - 4, new Zend_Pdf_Color_Html("#e7e7e7"));
             }
         }
         foreach ($rowset as $i => $col) {
             $style = new Zend_Pdf_Style();
             if ($params) {
                 $style->setFont(Model_Static_Fonts::get("Arial Narrow" . ($i == 0 && !$header ? ' Bold' : '')), $this->fontSizeFormat);
             } else {
                 $style->setFont(Model_Static_Fonts::get("Arial Narrow" . ($i == 0 && !$header ? ' Bold' : '')), $this->fontSizeFormatDiscription);
             }
             $style->setLineWidth($widths[$i]);
             // пишем клетку, и запоминаем макс высоту ( для многострочности )
             // выравнивание по центру значения таблицы с параметрами
             $width_text = $this->widthForStringUsingFontsize(trim($col), $style->getFont(), $style->getFontSize());
             if ($widths[$i] > $width_text && $params && $i != 0) {
                 $iLeft = $x + ($widths[$i] - $width_text) / 2;
                 $line_y = min($line_y, $this->drawTextBlock(str_replace('  ', ' ', trim($col)), $iLeft, $y, $style, -2));
             } elseif ($params && $i == 0) {
                 $iLeft = $x + 10;
                 $line_y = min($line_y, $this->drawTextBlock(str_replace('  ', ' ', trim($col)), $iLeft, $y, $style, -2));
             } else {
                 $iLeft = $x;
                 $line_y = min($line_y, $this->drawTextBlock(str_replace('  ', ' ', trim($col)), $iLeft, $y + 4, $style));
             }
             $x += $widths[$i];
         }
         $heightSnoski = 0;
         $y = $line_y;
         if ($header) {
             $style = new Zend_Pdf_Style();
             $style->setFont(Model_Static_Fonts::get("Arial Narrow"), $this->fontSizeFormatSnoski);
             $style->setLineWidth($width);
             $heightSnoski = $this->getTextBlockHeight($snoski, $style, 0, true);
         }
         // проверим, не вышли ли бы за границы высоты, но не в последнем элементе
         if ($y - 11 - $heightSnoski < 8 && count($table) == 1) {
             if ($header) {
                 $this->drawTextBlock($snoski, 5, $y, $style);
                 //$page -> setCurrentPosition($page -> getCurrentPosition());
             }
             if ($this->currentPosition > $y - $this->MARGIN['bottom']) {
                 $this->currentPosition = $y - $this->MARGIN['bottom'];
             }
             return NULL;
         }
         if ($y - $max_y - $heightSnoski < 8 && $c_row != count($table) - 1) {
             //
             if ($header) {
                 $this->drawTextBlock($snoski, 5, $y, $style);
                 //$page -> setCurrentPosition($page -> getCurrentPosition());
             }
             if ($this->currentPosition > $y - $this->MARGIN['bottom']) {
                 $this->currentPosition = $y - $this->MARGIN['bottom'];
             }
             return $c_row;
         }
     }
     //$this -> drawTextBlock($y,  -20, $y + 10, $style);
     if ($this->currentPosition > $y - $this->MARGIN['bottom']) {
         $this->currentPosition = $y - $this->MARGIN['bottom'];
     }
     // пишем сноски в конце блока с парамаетрами
     if ($header) {
         $style = new Zend_Pdf_Style();
         $style->setFont(Model_Static_Fonts::get("Arial Narrow"), $this->fontSizeFormatSnoski);
         $style->setLineWidth($width);
         $this->drawTextBlock($snoski, 5, $y, $style);
         //		$this -> drawTextBlock( $note, 5, $this -> getCurrentPosition() + 25, $style);
         //$this -> setCurrentPosition($this -> getCurrentPosition());
     }
     return NULL;
 }