本文整理汇总了PHP中Zend_Pdf_Page::drawText方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Page::drawText方法的具体用法?PHP Zend_Pdf_Page::drawText怎么用?PHP Zend_Pdf_Page::drawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Pdf_Page
的用法示例。
在下文中一共展示了Zend_Pdf_Page::drawText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDrawing
public function testDrawing()
{
$pdf = new Zend_Pdf();
// Add new page generated by Zend_Pdf object (page is attached to the specified the document)
$pdf->pages[] = $page1 = $pdf->newPage('A4');
// Add new page generated by Zend_Pdf_Page object (page is not attached to the document)
$pdf->pages[] = $page2 = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE);
// Create new font
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// Apply font and draw text
$page1->setFont($font, 36);
$page1->setFillColor(Zend_Pdf_Color_Html::color('#9999cc'));
$page1->drawText('Helvetica 36 text string', 60, 500);
// Use font object for another page
$page2->setFont($font, 24);
$page2->drawText('Helvetica 24 text string', 60, 500);
// Use another font
$page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32);
$page2->drawText('Times-Roman 32 text string', 60, 450);
// Draw rectangle
$page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8));
$page2->setLineColor(new Zend_Pdf_Color_GrayScale(0.2));
$page2->setLineDashingPattern(array(3, 2, 3, 4), 1.6);
$page2->drawRectangle(60, 400, 400, 350);
// Draw circle
$page2->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID);
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
$page2->drawCircle(85, 375, 25);
// Draw sectors
$page2->drawCircle(200, 375, 25, 2 * M_PI / 3, -M_PI / 6);
$page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0));
$page2->drawCircle(200, 375, 25, M_PI / 6, 2 * M_PI / 3);
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0));
$page2->drawCircle(200, 375, 25, -M_PI / 6, M_PI / 6);
// Draw ellipse
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
$page2->drawEllipse(250, 400, 400, 350);
$page2->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0));
$page2->drawEllipse(250, 400, 400, 350, M_PI / 6, 2 * M_PI / 3);
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0));
$page2->drawEllipse(250, 400, 400, 350, -M_PI / 6, M_PI / 6);
// Draw and fill polygon
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1));
$x = array();
$y = array();
for ($count = 0; $count < 8; $count++) {
$x[] = 140 + 25 * cos(3 * M_PI_4 * $count);
$y[] = 375 + 25 * sin(3 * M_PI_4 * $count);
}
$page2->drawPolygon($x, $y, Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, Zend_Pdf_Page::FILL_METHOD_EVEN_ODD);
// Draw line
$page2->setLineWidth(0.5);
$page2->drawLine(60, 375, 400, 375);
$pdf->save(dirname(__FILE__) . '/_files/output.pdf');
unset($pdf);
$pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
$this->assertTrue($pdf1 instanceof Zend_Pdf);
unset($pdf1);
unlink(dirname(__FILE__) . '/_files/output.pdf');
}
示例2: drawText3
/**
* Extension of basic draw-text function to allow it to vertically center text
*
* @param Zend_Pdf_Page $page
* @param string $text
* @param int $x1
* @param int $y1
* @param int $x2
* @param int $position
* @param string $encoding
* @return self
*/
public function drawText3(Zend_Pdf_Page $page, $text, $x1, $y1, $x2 = null, $position = self::TEXT_ALIGN_LEFT, $encoding = null)
{
die("RUN2");
print "lib";
$bottom = $y1;
// could do the same for vertical-centering
switch ($position) {
case self::TEXT_ALIGN_LEFT:
$left = $x1;
break;
case self::TEXT_ALIGN_RIGHT:
$text_width = $this->getTextWidth($text, $page->getFont(), $page->getFontSize());
$left = $x1 - $text_width;
break;
case self::TEXT_ALIGN_CENTER:
if (null === $x2) {
throw new Exception("Cannot center text horizontally, x2 is not provided");
}
$text_width = $this->getTextWidth($text, $page->getFont(), $page->getFontSize());
$box_width = $x2 - $x1;
$left = $x1 + ($box_width - $text_width) / 2;
break;
default:
throw new Exception("Invalid position value \"{$position}\"");
}
print "drawText({$line}, {$left}, {$bottom} - 0 * " . $page->getFontSize() . ", {$encoding});";
// display multi-line text
foreach (explode(PHP_EOL, $text) as $i => $line) {
$page->drawText($line, $left, $bottom - $i * $page->getFontSize(), $encoding);
}
return $this;
}
示例3: addPieceNumber
/**
* Add Piece Number
*
* @param int $pieceNumber
* @param int $piecesTotal
* @return Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder
* @throws InvalidArgumentException
* @throws Zend_Pdf_Exception
*/
public function addPieceNumber($pieceNumber, $piecesTotal)
{
$this->_page->saveGS();
if (!$pieceNumber || !$piecesTotal) {
throw new InvalidArgumentException(Mage::helper('usa')->__('Piece number information is missing'));
}
$this->_page->setFont($this->_fontNormal, 6);
$this->_page->drawText('Piece:', $this->_x(256), $this->_y(224));
$this->_page->setFont($this->_fontBold, 11);
$this->_page->drawText($pieceNumber . '/' . $piecesTotal, $this->_x(256), $this->_y(234));
$this->_page->restoreGS();
return $this;
}
示例4: _drawHeader
protected function _drawHeader(Zend_Pdf_Page $page)
{
$font = $page->getFont();
$size = $page->getFontSize();
$page->drawText(Mage::helper('sales')->__('Products'), $x = 35, $this->y, 'UTF-8');
$x += 220;
$page->drawText(Mage::helper('sales')->__('SKU'), $x, $this->y, 'UTF-8');
$x += 100;
$text = Mage::helper('sales')->__('Total (ex)');
$page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
$x += 50;
$text = Mage::helper('sales')->__('Discount');
$page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
$x += 50;
$text = Mage::helper('sales')->__('Qty');
$page->drawText($text, $this->getAlignCenter($text, $x, 30, $font, $size), $this->y, 'UTF-8');
$x += 30;
$text = Mage::helper('sales')->__('Tax');
$page->drawText($text, $this->getAlignRight($text, $x, 45, $font, $size, 10), $this->y, 'UTF-8');
$x += 45;
$text = Mage::helper('sales')->__('Total (inc)');
$page->drawText($text, $this->getAlignRight($text, $x, 570 - $x, $font, $size), $this->y, 'UTF-8');
}
开发者ID:shashankkanungo,项目名称:magento,代码行数:23,代码来源:SM_Vendors_Model_Override_Sales_Order_Pdf_Creditmemo.php
示例5: _printComments
protected function _printComments($order, Zend_Pdf_Page $page)
{
if (Mage::helper('core')->isModuleEnabled('Magemaven_OrderComment') && ($order->getCustomerComment() || $order->getCustomerNote())) {
$comment = Mage::helper('ordercomment')->escapeHtml($order->getCustomerComment() ? $order->getCustomerComment() : $order->getCustomerNote());
$this->y -= 15;
$page->drawText(Mage::helper('ordercomment')->__('Order Comment'), 35, $this->y, 'UTF-8');
$this->y -= 15;
$leftToPrint = explode(' ', $comment);
$availableWidth = $page->getWidth();
while (!empty($leftToPrint)) {
$currentLine = $leftToPrint;
$leftToPrint = array();
while ($this->widthForStringUsingFontSize(implode(' ', $currentLine), $page->getFont(), $page->getFontSize()) > $availableWidth) {
$leftToPrint[] = array_pop($currentLine);
}
$page->drawText(implode(' ', $currentLine), 35, $this->y, 'UTF-8');
}
}
}
示例6: drawFont
protected function drawFont($object)
{
$fontItem = $object->getItem();
if ($fontItem->getFace() == 'bold') {
$fontDecoration = 'bold';
} else {
$fontDecoration = 'regular';
}
$fontPath = SERVER_BASE . '/fonts/' . $fontItem->getName() . '.ttf';
if (is_file($fontPath)) {
$font = Zend_Pdf_Font::fontWithPath($fontPath, Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION);
} else {
if ($fontDecoration == "bold") {
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
} else {
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
}
}
if ($fontItem->getFace() == "invert") {
$this->page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
//schwarze farbe setzen fuer Hintergrund
$width = $this->widthForStringUsingFontSize($object->getValue(), $font, $fontItem->getSize());
$height = $fontItem->getSize();
$this->page->drawRectangle($this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy())) + $height / 2, $this->coordX($this->mmToPts($object->getPosx())) + $width, $this->coordY($this->mmToPts($object->getPosy())) - $height / 2, Zend_Pdf_Page::SHAPE_DRAW_FILL);
$this->page->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 1));
//weiße farbe setzen fuer Text
} else {
$this->page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0));
//schwarze farbe setzen fuer text
}
$this->page->setFont($font, $fontItem->getSize());
if ($fontItem->getRotation() !== null) {
$this->page->rotate($this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy())), deg2rad(360 - $fontItem->getRotation()));
}
$this->page->drawText($object->getValue(), $this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy()) + $fontItem->getSize() / 2), 'UTF-8');
if ($fontItem->getRotation() !== null) {
$this->page->rotate($this->coordX($this->mmToPts($object->getPosx())), $this->coordY($this->mmToPts($object->getPosy())), -deg2rad(360 - $fontItem->getRotation()));
}
}
示例7: testPageCloning
public function testPageCloning()
{
$pdf = Zend_Pdf::load(dirname(__FILE__) . '/_files/pdfarchiving.pdf');
$srcPageCount = count($pdf->pages);
try {
$newPage = clone reset($pdf->pages);
} catch (Zend_Pdf_Exception $e) {
if (strpos($e->getMessage(), 'Cloning Zend_Pdf_Page object using \'clone\' keyword is not supported.') !== 0) {
throw $e;
}
// Exception is thrown
}
$outputPageSet = array();
foreach ($pdf->pages as $srcPage) {
$page = new Zend_Pdf_Page($srcPage);
$outputPageSet[] = $srcPage;
$outputPageSet[] = $page;
$page->saveGS();
// Create new Style
$page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0.9))->setLineColor(new Zend_Pdf_Color_GrayScale(0.2))->setLineWidth(3)->setLineDashingPattern(array(3, 2, 3, 4), 1.6)->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32);
$page->rotate(0, 0, M_PI_2 / 3);
$page->drawText('Modified by Zend Framework!', 150, 0);
$page->restoreGS();
}
// Add new page generated by Zend_Pdf object (page is attached to the specified the document)
$pdf->pages = $outputPageSet;
$pdf->save(dirname(__FILE__) . '/_files/output.pdf');
unset($pdf);
$pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
$this->assertTrue($pdf1 instanceof Zend_Pdf);
$this->assertEquals($srcPageCount * 2, count($pdf1->pages));
unset($pdf1);
unlink(dirname(__FILE__) . '/_files/output.pdf');
}
示例8: addTokenToPage
/**
* Add the token to a pdf page
*
* @param \Zend_Pdf_Page $page
* @param string $tokenId
*/
protected function addTokenToPage(\Zend_Pdf_Page $page, $tokenId)
{
// Set $this->pageFont to false to prevent drawing of tokens on page.
if ($this->pageFont) {
$font = \Zend_Pdf_Font::fontWithName($this->pageFont);
if ($this->pageXfromLeft) {
$x = $this->pageX;
} else {
$x = $page->getWidth() - $this->pageX;
}
if ($this->pageYfromTop) {
$y = $page->getHeight() - $this->pageY;
} else {
$y = $this->pageY;
}
$page->setFont($font, $this->pageFontSize);
$page->drawText(strtoupper($tokenId), $x, $y, 'UTF-8');
}
}
示例9: DrawHeader
protected static function DrawHeader(Zend_Pdf_Page $objPage)
{
$intY = STEWARDSHIP_TOP - 5 / 8 * 72;
$intY -= 13.2;
$objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12);
$objPage->drawText(STEWARDSHIP_STATEMENT_LINE_1, 36, $intY, 'UTF-8');
$intY -= 9.199999999999999;
$objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 8);
$objPage->drawText(STEWARDSHIP_STATEMENT_LINE_2, 36, $intY, 'UTF-8');
$intY -= 12.1;
$objPage->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 11);
$objPage->drawText(STEWARDSHIP_STATEMENT_LINE_3, 36, $intY, 'UTF-8');
$intY -= 12.1;
$objPage->drawText(STEWARDSHIP_STATEMENT_LINE_4, 36, $intY, 'UTF-8');
if (!self::$ZendImage) {
self::$ZendImage = Zend_Pdf_Image::imageWithPath(__DOCROOT__ . __IMAGE_ASSETS__ . '/alcf_logo_stewardship.png');
}
$objPage->drawImage(self::$ZendImage, 424, STEWARDSHIP_TOP - 108, 576, STEWARDSHIP_TOP - 36);
}
示例10:
$pdf->pages[] = ($page1 = $pdf->newPage('A4'));
// Add new page generated by Zend_Pdf_Page object (page is not attached to the document)
$pdf->pages[] = ($page2 = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE));
// Create new font
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// Apply font and draw text
$page1->setFont($font, 36);
$page1->setFillColor(Zend_Pdf_Color_Html::color('#9999cc'));
$page1->drawText('Helvetica 36 text string', 60, 500);
// Use font object for another page
$page2->setFont($font, 24);
$page2->drawText('Helvetica 24 text string', 60, 500);
// Use another font
$page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32);
$page2->drawText('Times-Roman 32 text string', 60, 450);
// Draw rectangle
$page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8));
$page2->setLineColor(new Zend_Pdf_Color_GrayScale(0.2));
$page2->setLineDashingPattern(array(3, 2, 3, 4), 1.6);
$page2->drawRectangle(60, 400, 400, 350);
// Draw circle
$page2->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID);
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
$page2->drawCircle(85, 375, 25);
示例11: _drawRmaItem
/**
* Draw one line - rma item
*
* @param Enterprise_Rma_Model_Item $item
* @param Zend_Pdf_Page $page
*/
protected function _drawRmaItem($item, $page)
{
$shift = 0;
foreach (Mage::helper('core/string')->str_split($item->getProductName(), 40, true, true) as $key => $part) {
$page->drawText($part, $this->getProductNameX(), $this->y - $shift, 'UTF-8');
$shift += 10;
}
$shift = 0;
foreach (Mage::helper('core/string')->str_split($item->getProductSku(), 18) as $key => $part) {
$page->drawText($part, $this->getProductSkuX(), $this->y - $shift, 'UTF-8');
$shift += 10;
}
$condition = Mage::helper('core/string')->str_split($this->_getOptionAttributeStringValue($item->getCondition()), 25);
$page->drawText($condition[0], $this->getConditionX(), $this->y, 'UTF-8');
$resolution = Mage::helper('core/string')->str_split($this->_getOptionAttributeStringValue($item->getResolution()), 25);
$page->drawText($resolution[0], $this->getResolutionX(), $this->y, 'UTF-8');
$page->drawText(Mage::helper('enterprise_rma')->parseQuantity($item->getQtyRequested(), $item), $this->getQtyRequestedX(), $this->y, 'UTF-8');
$page->drawText(Mage::helper('enterprise_rma')->getQty($item), $this->getQtyX(), $this->y, 'UTF-8');
$status = Mage::helper('core/string')->str_split($item->getStatusLabel(), 25);
$page->drawText($status[0], $this->getStatusX(), $this->y, 'UTF-8');
$productOptions = $item->getOptions();
if (is_array($productOptions) && !empty($productOptions)) {
$this->_drawCustomOptions($productOptions, $page);
}
$this->y -= 10;
}
示例12: drawText
public function drawText($text, $x, $y, $charEncoding = 'UTF-8')
{
parent::drawText($text, $x, $y, 'UTF-8');
return $this;
}
示例13: dirname
<?php
header('Content-Type: application/x-pdf');
header("Content-Disposition: attachment;filename=invoice.pdf");
header("Cache-Control: no-cache, must-revalidate");
$path = dirname(dirname(__FILE__)) . '/library';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once "Zend/Pdf.php";
$pdf = new Zend_Pdf();
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER);
$pdf->pages[] = $page;
$pdf->pages[] = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
$page->setFont($font, 12);
$page->drawText('wewe', 110, 641);
//echo $page->getHeight();
//echo $page->getWidth();
$pdf->save("report2.pdf");
header('Location: report2.pdf');
示例14: _drawHeader
protected function _drawHeader(Zend_Pdf_Page $page, $order)
{
if ($order instanceof Mage_Sales_Model_Order && (!$order->getDcOrderId() || $order->getDeliveryDutyType() == Dutycalculator_Charge_Helper_Data::DC_DELIVERY_TYPE_DDU || $order->getFailedCalculation())) {
$font = $page->getFont();
$size = $page->getFontSize();
$page->drawText(Mage::helper('sales')->__('Products'), $x = 35, $this->y, 'UTF-8');
$x += 220;
$page->drawText(Mage::helper('sales')->__('SKU'), $x, $this->y, 'UTF-8');
$x += 100;
$text = Mage::helper('sales')->__('Total (ex)');
$page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
$x += 50;
$text = Mage::helper('sales')->__('Discount');
$page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
$x += 50;
$text = Mage::helper('sales')->__('Qty');
$page->drawText($text, $this->getAlignCenter($text, $x, 30, $font, $size), $this->y, 'UTF-8');
$x += 30;
$text = Mage::helper('sales')->__('Tax');
$page->drawText($text, $this->getAlignRight($text, $x, 45, $font, $size, 10), $this->y, 'UTF-8');
$x += 45;
$text = Mage::helper('sales')->__('Total (inc)');
$page->drawText($text, $this->getAlignRight($text, $x, 570 - $x, $font, $size), $this->y, 'UTF-8');
} else {
$font = $page->getFont();
$size = $page->getFontSize();
$page->drawText(Mage::helper('sales')->__('Products'), $x = 35, $this->y, 'UTF-8');
$x += 200;
//220
$page->drawText(Mage::helper('sales')->__('SKU'), $x, $this->y, 'UTF-8');
$x += 80;
//100
$text = Mage::helper('sales')->__('Total (ex)');
$page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
$x += 50;
$text = Mage::helper('sales')->__('Discount');
$page->drawText($text, $this->getAlignRight($text, $x, 50, $font, $size), $this->y, 'UTF-8');
$x += 50;
$text = Mage::helper('sales')->__('Qty');
$page->drawText($text, $this->getAlignCenter($text, $x, 30, $font, $size), $this->y, 'UTF-8');
$x += 30;
$text = Mage::helper('dccharge')->__('Sales Tax');
$page->drawText($text, $this->getAlignRight($text, $x, 40, $font, $size, 10), $this->y, 'UTF-8');
$x += 40;
//45
$text = Mage::helper('dccharge')->__('Import Duty');
$page->drawText($text, $this->getAlignRight($text, $x, 45, $font, $size, 10), $this->y, 'UTF-8');
$x += 45;
//45
$text = Mage::helper('sales')->__('Total (inc)');
$page->drawText($text, $this->getAlignRight($text, $x, 570 - $x, $font, $size), $this->y, 'UTF-8');
}
}
示例15: downloadAction
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());
}
}