本文整理汇总了PHP中Zend_Pdf_Page类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Page类的具体用法?PHP Zend_Pdf_Page怎么用?PHP Zend_Pdf_Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Pdf_Page类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addNext
public function addNext($giftCard)
{
$template = $giftCard->getTemplate();
if (!$template) {
return false;
}
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$draw = Mage::getModel('giftcard/giftcard_draw');
$draw->setGiftCard($giftCard);
$draw->setTemplate($template);
$draw->drawGiftCard();
if (!($imagePath = $draw->getImagePath())) {
return false;
}
$image = Zend_Pdf_Image::imageWithPath($imagePath);
$imgWidthPts = $image->getPixelWidth() * 72 / 96;
$imgHeightPts = $image->getPixelHeight() * 72 / 96;
$rate = $imgWidthPts / $page->getWidth();
$imgWidthPts = $imgWidthPts / $rate;
$imgHeightPts = $imgHeightPts / $rate;
$pageHeight = $page->getHeight();
$page->drawImage($image, 0, $pageHeight - $imgHeightPts, $imgWidthPts, $pageHeight);
$this->addPage($page);
unlink($imagePath);
return true;
}
开发者ID:kemeice,项目名称:Giftcards,代码行数:26,代码来源:Pdf.php
示例2: create
/**
* Create destination object
*
* @param Zend_Pdf_Page|integer $page Page object or page number
* @param float $left Left edge of displayed page
* @param float $top Top edge of displayed page
* @param float $zoom Zoom factor
* @return Zend_Pdf_Destination_Zoom
* @throws Zend_Pdf_Exception
*/
public static function create($page, $left = null, $top = null, $zoom = null)
{
$destinationArray = new Zend_Pdf_Element_Array();
if ($page instanceof Zend_Pdf_Page) {
$destinationArray->items[] = $page->getPageDictionary();
} else {
if (is_integer($page)) {
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
} else {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
}
}
$destinationArray->items[] = new Zend_Pdf_Element_Name('XYZ');
if ($left === null) {
$destinationArray->items[] = new Zend_Pdf_Element_Null();
} else {
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
}
if ($top === null) {
$destinationArray->items[] = new Zend_Pdf_Element_Null();
} else {
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
}
if ($zoom === null) {
$destinationArray->items[] = new Zend_Pdf_Element_Null();
} else {
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($zoom);
}
return new Zend_Pdf_Destination_Zoom($destinationArray);
}
开发者ID:basdog22,项目名称:Qool,代码行数:41,代码来源:Zoom.php
示例3: _drawLine
/**
* Draw Line for page
*
* @param Zend_Pdf_Page $page
* @return void
*/
protected function _drawLine(Zend_Pdf_Page $page)
{
//$this->_setFontRegular($page, 9);
//$page->setLineColor(new Zend_Pdf_Color_GrayScale(0));
$page->setLineWidth(1);
$page->drawLine(25, $this->y - 15, 570, $this->y - 15);
}
开发者ID:VinuWebtech,项目名称:production267,代码行数:13,代码来源:Invoice.php
示例4: getPdf
public function getPdf()
{
$pdf = new Zend_Pdf();
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
$page->setFont($font, 12);
$width = $page->getWidth();
$i = 0;
$this->insertLogo($page);
$this->insertAddress($page);
/*$page->setFillColor(new Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
$page->drawRectangle(25, $this->y + 15, 190, $this->y - 35);
$page->drawRectangle(190, $this->y + 15, 350, $this->y - 35);
$page->drawRectangle(350, $this->y + 15, 570, $this->y - 35);*/
$page->setFont($font, 16);
$this->y -= 50;
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0.5));
$page->drawRectangle(25, $this->y + 15, 573, $this->y - 57);
$page->setFillColor(new Zend_Pdf_Color_Html('#ffffff'));
$headerText = "Report: Net Sales & Tax";
$page->drawText($headerText, 30, $this->y, 'UTF-8');
$this->y -= 22;
$page->drawText("From: " . $this->from, 30, $this->y, 'UTF-8');
$this->y -= 22;
$page->drawText("To: " . $this->to, 30, $this->y, 'UTF-8');
$page->setFont($font, 14);
$this->y -= 50;
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
$totalText = Mage::helper('sales')->__('Total Net Sale');
$page->drawText($totalText, 25, $this->y, 'UTF-8');
$total = Mage::helper('core')->currency($this->getTotalSale(), true, false);
$page->drawText($total, 505, $this->y, 'UTF-8');
$this->y -= 50;
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
$totalText = Mage::helper('sales')->__('Net Sales Texas Only');
$page->drawText($totalText, 25, $this->y, 'UTF-8');
$total = Mage::helper('core')->currency($this->getTotalTexasSale(), true, false);
$page->drawText($total, 505, $this->y, 'UTF-8');
$this->y -= 50;
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
$totalText = Mage::helper('sales')->__('Net Shipping Costs for Texas only');
$page->drawText($totalText, 25, $this->y, 'UTF-8');
$total = Mage::helper('core')->currency($this->getTotalTexasShipping(), true, false);
$page->drawText($total, 505, $this->y, 'UTF-8');
$this->y -= 50;
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
$totalText = Mage::helper('sales')->__('Texas Net Sales Tax');
$page->drawText($totalText, 25, $this->y, 'UTF-8');
$total = Mage::helper('core')->currency($this->getTotalTexasTax(), true, false);
$page->drawText($total, 505, $this->y, 'UTF-8');
$pdf->pages[] = $page;
return $pdf->render();
}
开发者ID:buttasg,项目名称:cowgirlk,代码行数:53,代码来源:Sale0.php
示例5: create
/**
* Create destination object
*
* @param Zend_Pdf_Page|integer $page Page object or page number
* @return Zend_Pdf_Destination_FitBoundingBox
* @throws Zend_Pdf_Exception
*/
public static function create($page)
{
$destinationArray = new Zend_Pdf_Element_Array();
if ($page instanceof Zend_Pdf_Page) {
$destinationArray->items[] = $page->getPageDictionary();
} elseif (is_integer($page)) {
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
} else {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
}
$destinationArray->items[] = new Zend_Pdf_Element_Name('FitB');
return new Zend_Pdf_Destination_FitBoundingBox($destinationArray);
}
开发者ID:Cryde,项目名称:sydney-core,代码行数:21,代码来源:FitBoundingBox.php
示例6: 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;
}
开发者ID:Tetting,项目名称:Shorty,代码行数:44,代码来源:ZendPdfExtend.php
示例7: create
/**
* Create destination object
*
* @param Zend_Pdf_Page|integer $page Page object or page number
* @param float $left Left edge of displayed page
* @return Zend_Pdf_Destination_FitVertically
* @throws Zend_Pdf_Exception
*/
public static function create($page, $left)
{
$destinationArray = new Zend_Pdf_Element_Array();
if ($page instanceof Zend_Pdf_Page) {
$destinationArray->items[] = $page->getPageDictionary();
} else {
if (is_integer($page)) {
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
} else {
//$1 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or page number.');
}
}
$destinationArray->items[] = new Zend_Pdf_Element_Name('FitV');
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
return new Zend_Pdf_Destination_FitVertically($destinationArray);
}
开发者ID:netconstructor,项目名称:Centurion,代码行数:25,代码来源:FitVertically.php
示例8: createContent
protected function createContent(\Zend_Pdf_Page $page)
{
$page->setLineWidth(2);
$page->drawLine(30, 400, 810, 400);
$em = EntityManager::getInstance();
$where = "settlement_total_id = " . $this->_settlement->getIdentifier();
$settlements = $em->findAll("Settlement", $where);
$lines = count($settlements) + 1;
$this->setFont($page);
$page->drawText("Lp.", 40, 383);
$page->drawText("Nazwisko i imię klienta", 90, 383, "UTF-8");
$page->drawText("Partner", 270, 383);
$page->drawText("Produkt", 390, 383);
$page->drawText("Transza", 520, 383);
$page->drawText("Kwota", 625, 383);
$page->drawText("Forma wynagrodzenia", 685, 383);
$lineHeight = 25;
for ($i = 0; $i <= $lines; $i++) {
$page->drawLine(30, 400 - $i * $lineHeight, 810, 400 - $i * $lineHeight);
if ($i > 0 && $i < $lines) {
$settlement = $settlements[$i - 1];
$page->drawText($i, 45, 383 - $i * $lineHeight);
$customer = $settlement->application->customer->lastname . ' ' . $settlement->application->customer->firstname;
$page->drawText($customer, 80, 383 - $i * $lineHeight, "UTF-8");
$page->drawText($settlement->application->partner->name, 240, 383 - $i * $lineHeight, "UTF-8");
$page->drawText($settlement->application->product->name, 360, 383 - $i * $lineHeight, "UTF-8");
$page->drawText($settlement->parts, 480, 383 - $i * $lineHeight, 'UTF-8');
$page->drawText($settlement->amount, 630, 383 - $i * $lineHeight);
$page->drawText($settlement->application->settlementType->name, 725, 383 - $i * $lineHeight);
}
}
$bottomY = 383 - $i * $lineHeight + $lineHeight;
$page->drawLine(30, 400, 30, 400 - $lines * $lineHeight);
$page->drawLine(70, 400, 70, 400 - $lines * $lineHeight);
$page->drawLine(230, 400, 230, 400 - $lines * $lineHeight);
$page->drawLine(350, 400, 350, 400 - $lines * $lineHeight);
$page->drawLine(470, 400, 470, 400 - $lines * $lineHeight);
$page->drawLine(610, 400, 610, 400 - ($lines + 1) * $lineHeight);
$page->drawLine(675, 400, 675, 400 - ($lines + 1) * $lineHeight);
$page->drawLine(810, 400, 810, 400 - $lines * $lineHeight);
$page->drawLine(470, 400 - $lines * $lineHeight, 470, 400 - ($lines + 1) * $lineHeight);
$page->drawLine(470, 400 - ($lines + 1) * $lineHeight, 675, 400 - ($lines + 1) * $lineHeight);
$this->setFont($page);
$page->drawText("Razem", 520, 383 - $lines * $lineHeight);
$page->drawText($this->_settlement->total, 630, 383 - $lines * $lineHeight);
}
开发者ID:sp1ke77,项目名称:MLM-1,代码行数:46,代码来源:Creator.php
示例9: create
/**
* Create destination object
*
* @param Zend_Pdf_Page|integer $page Page object or page number
* @param float $left Left edge of displayed page
* @param float $bottom Bottom edge of displayed page
* @param float $right Right edge of displayed page
* @param float $top Top edge of displayed page
* @return Zend_Pdf_Destination_FitRectangle
* @throws Zend_Pdf_Exception
*/
public static function create($page, $left, $bottom, $right, $top)
{
$destinationArray = new Zend_Pdf_Element_Array();
if ($page instanceof Zend_Pdf_Page) {
$destinationArray->items[] = $page->getPageDictionary();
} elseif (is_integer($page)) {
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
} else {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
}
$destinationArray->items[] = new Zend_Pdf_Element_Name('FitR');
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($bottom);
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($right);
$destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
return new Zend_Pdf_Destination_FitRectangle($destinationArray);
}
开发者ID:Cryde,项目名称:sydney-core,代码行数:29,代码来源:FitRectangle.php
示例10: _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');
}
}
}
开发者ID:mgomse,项目名称:emailattachments,代码行数:19,代码来源:Order.php
示例11: _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
示例12: _drawPackageBlock
/**
* Draw packages block
*
* @param \Zend_Pdf_Page $page
* @return \Magento\Shipping\Model\Order\Pdf\Packaging
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
protected function _drawPackageBlock(\Zend_Pdf_Page $page)
{
if ($this->getPackageShippingBlock()) {
$packaging = $this->getPackageShippingBlock();
} else {
$packaging = $this->_layout->getBlockSingleton('Magento\\Shipping\\Block\\Adminhtml\\Order\\Packaging');
}
$packages = $packaging->getPackages();
$packageNum = 1;
foreach ($packages as $package) {
$page->setFillColor(new \Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
$page->drawRectangle(25, $this->y + 15, 190, $this->y - 35);
$page->drawRectangle(190, $this->y + 15, 350, $this->y - 35);
$page->drawRectangle(350, $this->y + 15, 570, $this->y - 35);
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
$page->drawRectangle(520, $this->y + 15, 570, $this->y - 5);
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
$packageText = __('Package') . ' ' . $packageNum;
$page->drawText($packageText, 525, $this->y, 'UTF-8');
$packageNum++;
$package = new \Magento\Framework\DataObject($package);
$params = new \Magento\Framework\DataObject($package->getParams());
$dimensionUnits = $this->_carrierHelper->getMeasureDimensionName($params->getDimensionUnits());
$typeText = __('Type') . ' : ' . $packaging->getContainerTypeByCode($params->getContainer());
$page->drawText($typeText, 35, $this->y, 'UTF-8');
if ($params->getLength() != null) {
$lengthText = $params->getLength() . ' ' . $dimensionUnits;
} else {
$lengthText = '--';
}
$lengthText = __('Length') . ' : ' . $lengthText;
$page->drawText($lengthText, 200, $this->y, 'UTF-8');
if ($params->getDeliveryConfirmation() != null) {
$confirmationText = __('Signature Confirmation') . ' : ' . $packaging->getDeliveryConfirmationTypeByCode($params->getDeliveryConfirmation());
$page->drawText($confirmationText, 355, $this->y, 'UTF-8');
}
$this->y = $this->y - 10;
if ($packaging->displayCustomsValue() != null) {
$customsValueText = __('Customs Value') . ' : ' . $packaging->displayPrice($params->getCustomsValue());
$page->drawText($customsValueText, 35, $this->y, 'UTF-8');
}
if ($params->getWidth() != null) {
$widthText = $params->getWidth() . ' ' . $dimensionUnits;
} else {
$widthText = '--';
}
$widthText = __('Width') . ' : ' . $widthText;
$page->drawText($widthText, 200, $this->y, 'UTF-8');
if ($params->getContentType() != null) {
if ($params->getContentType() == 'OTHER') {
$contentsValue = $params->getContentTypeOther();
} else {
$contentsValue = $packaging->getContentTypeByCode($params->getContentType());
}
$contentsText = __('Contents') . ' : ' . $contentsValue;
$page->drawText($contentsText, 355, $this->y, 'UTF-8');
}
$this->y = $this->y - 10;
$weightText = __('Total Weight') . ' : ' . $params->getWeight() . ' ' . $this->_carrierHelper->getMeasureWeightName($params->getWeightUnits());
$page->drawText($weightText, 35, $this->y, 'UTF-8');
if ($params->getHeight() != null) {
$heightText = $params->getHeight() . ' ' . $dimensionUnits;
} else {
$heightText = '--';
}
$heightText = __('Height') . ' : ' . $heightText;
$page->drawText($heightText, 200, $this->y, 'UTF-8');
$this->y = $this->y - 10;
if ($params->getSize()) {
$sizeText = __('Size') . ' : ' . ucfirst(strtolower($params->getSize()));
$page->drawText($sizeText, 35, $this->y, 'UTF-8');
}
if ($params->getGirth() != null) {
$dimensionGirthUnits = $this->_carrierHelper->getMeasureDimensionName($params->getGirthDimensionUnits());
$girthText = __('Girth') . ' : ' . $params->getGirth() . ' ' . $dimensionGirthUnits;
$page->drawText($girthText, 200, $this->y, 'UTF-8');
}
$this->y = $this->y - 5;
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
$page->drawRectangle(25, $this->y, 570, $this->y - 30 - count($package->getItems()) * 12);
$this->y = $this->y - 10;
$page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
$page->drawText(__('Items in the Package'), 30, $this->y, 'UTF-8');
$txtIndent = 5;
$itemCollsNumber = $packaging->displayCustomsValue() ? 5 : 4;
$itemCollsX[0] = 30;
// coordinate for Product name
$itemCollsX[1] = 250;
// coordinate for Product name
$itemCollsXEnd = 565;
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:101,代码来源:Packaging.php
示例13: _setFontItalic
/**
* Set font as italic
*
* @param \Zend_Pdf_Page $object
* @param int $size
* @return \Zend_Pdf_Resource_Font
*/
protected function _setFontItalic($object, $size = 7)
{
$font = \Zend_Pdf_Font::fontWithPath($this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_It-2.8.2.ttf'));
$object->setFont($font, $size);
return $font;
}
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:AbstractPdf.php
示例14: createPdfPageFromImageString
/**
* Create Zend_Pdf_Page instance with image from $imageString. Supports JPEG, PNG, GIF, WBMP, and GD2 formats.
*
* @param string $imageString
* @return Zend_Pdf_Page|bool
*/
public function createPdfPageFromImageString($imageString)
{
$image = imagecreatefromstring($imageString);
if (!$image) {
return false;
}
$xSize = imagesx($image);
$ySize = imagesy($image);
$page = new Zend_Pdf_Page($xSize, $ySize);
imageinterlace($image, 0);
$tmpFileName = sys_get_temp_dir() . DS . 'shipping_labels_' . uniqid(mt_rand()) . time() . '.png';
imagepng($image, $tmpFileName);
$pdfImage = Zend_Pdf_Image::imageWithPath($tmpFileName);
$page->drawImage($pdfImage, 0, 0, $xSize, $ySize);
unlink($tmpFileName);
return $page;
}
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:23,代码来源:Shipping.php
示例15: 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');
}
开发者ID:jsnshrmn,项目名称:Suma,代码行数:34,代码来源:ProcessingTest.php
示例16: createPdfPageFromImageString
/**
* Create \Zend_Pdf_Page instance with image from $imageString. Supports JPEG, PNG, GIF, WBMP, and GD2 formats.
*
* @param string $imageString
* @return \Zend_Pdf_Page|false
*/
public function createPdfPageFromImageString($imageString)
{
/** @var \Magento\Framework\Filesystem\Directory\Write $directory */
$directory = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
$directory->create();
$image = @imagecreatefromstring($imageString);
if (!$image) {
return false;
}
$xSize = imagesx($image);
$ySize = imagesy($image);
$page = new \Zend_Pdf_Page($xSize, $ySize);
imageinterlace($image, 0);
$tmpFileName = $directory->getAbsolutePath('shipping_labels_' . uniqid(\Magento\Framework\Math\Random::getRandomNumber()) . time() . '.png');
imagepng($image, $tmpFileName);
$pdfImage = \Zend_Pdf_Image::imageWithPath($tmpFileName);
$page->drawImage($pdfImage, 0, 0, $xSize, $ySize);
$directory->delete($directory->getRelativePath($tmpFileName));
return $page;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:26,代码来源:LabelGenerator.php
示例17: 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);
// Add new page generated by Zend_Pdf_Page object (page is attached to the document)
$pdf->pages[] = $page3 = $pdf->newPage('A4');
// Create new font
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// Apply font and draw text
$page1->setFont($font, 36)->setFillColor(Zend_Pdf_Color_Html::color('#9999cc'))->drawText('Helvetica 36 text string', 60, 500);
// Use font object for another page
$page2->setFont($font, 24)->drawText('Helvetica 24 text string', 60, 500);
// Use another font
$page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32)->drawText('Times-Roman 32 text string', 60, 450);
// Draw rectangle
$page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8))->setLineColor(new Zend_Pdf_Color_GrayScale(0.2))->setLineDashingPattern(array(3, 2, 3, 4), 1.6)->drawRectangle(60, 400, 500, 350);
// Draw rounded rectangle
$page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.9))->setLineColor(new Zend_Pdf_Color_GrayScale(0.5))->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID)->drawRoundedRectangle(425, 350, 475, 400, 20);
// Draw circle
$page2->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID)->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0))->drawCircle(85, 375, 25);
// Draw sectors
$page2->drawCircle(200, 375, 25, 2 * M_PI / 3, -M_PI / 6)->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0))->drawCircle(200, 375, 25, M_PI / 6, 2 * M_PI / 3)->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0))->drawCircle(200, 375, 25, -M_PI / 6, M_PI / 6);
// Draw ellipse
$page2->setFillColor(new Zend_Pdf_Color_Html('Red'))->drawEllipse(250, 400, 400, 350)->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0))->drawEllipse(250, 400, 400, 350, M_PI / 6, 2 * M_PI / 3)->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0))->drawEllipse(250, 400, 400, 350, -M_PI / 6, M_PI / 6);
// Draw and fill polygon
$page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1));
$x = array();
$y = array();
for ($count = 0; $count < 8; $count++) {
$x[] = 140 + 25 * cos(3 * M_PI_4 * $count);
$y[] = 375 + 25 * sin(3 * M_PI_4 * $count);
}
$page2->drawPolygon($x, $y, Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, Zend_Pdf_Page::FILL_METHOD_EVEN_ODD);
// Draw line
$page2->setLineWidth(0.5)->drawLine(60, 375, 500, 375);
// -----------------------------------------------------------------------------------
$page3->translate(200, 10)->rotate(10, 10, M_PI_2 / 9)->scale(0.7, 1.2)->skew(60, 350, M_PI_2 / 9, -M_PI_2 / 9);
// Use font object for another page
$page3->setFont($font, 24)->drawText('Helvetica 24 text string', 60, 500);
// Use another font
$page3->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32)->drawText('Times-Roman 32 text string', 60, 450);
// Draw rectangle
$page3->setFillColor(new Zend_Pdf_Color_GrayScale(0.8))->setLineColor(new Zend_Pdf_Color_GrayScale(0.2))->setLineDashingPattern(array(3, 2, 3, 4), 1.6)->drawRectangle(60, 400, 500, 350);
// Draw rounded rectangle
$page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.9))->setLineColor(new Zend_Pdf_Color_GrayScale(0.5))->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID)->drawRoundedRectangle(425, 350, 475, 400, 20);
// Draw circle
$page3->setLineDashingPattern(Zend_Pdf_Page::LINE_DASHING_SOLID)->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 0))->drawCircle(85, 375, 25);
// Draw sectors
$page3->drawCircle(200, 375, 25, 2 * M_PI / 3, -M_PI / 6)->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0))->drawCircle(200, 375, 25, M_PI / 6, 2 * M_PI / 3)->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0))->drawCircle(200, 375, 25, -M_PI / 6, M_PI / 6);
// Draw ellipse
$page3->setFillColor(new Zend_Pdf_Color_Html('Red'))->drawEllipse(250, 400, 400, 350)->setFillColor(new Zend_Pdf_Color_Cmyk(1, 0, 0, 0))->drawEllipse(250, 400, 400, 350, M_PI / 6, 2 * M_PI / 3)->setFillColor(new Zend_Pdf_Color_Rgb(1, 1, 0))->drawEllipse(250, 400, 400, 350, -M_PI / 6, M_PI / 6);
// Draw and fill polygon
$page3->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1));
$x = array();
$y = array();
for ($count = 0; $count < 8; $count++) {
$x[] = 140 + 25 * cos(3 * M_PI_4 * $count);
$y[] = 375 + 25 * sin(3 * M_PI_4 * $count);
}
$page3->drawPolygon($x, $y, Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, Zend_Pdf_Page::FILL_METHOD_EVEN_ODD);
// Draw line
$page3->setLineWidth(0.5)->drawLine(60, 375, 500, 375);
$pdf->save(dirname(__FILE__) . '/_files/output.pdf');
unset($pdf);
$pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
$this->assertTrue($pdf1 instanceof Zend_Pdf);
unset($pdf1);
unlink(dirname(__FILE__) . '/_files/output.pdf');
}
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:72,代码来源:DrawingTest.php
示例18: _prepareText
/**
* Prepares the text so that it fits to the given page's width.
*
* @param string $text the text which should be prepared
* @param Zend_Pdf_Page $page the page on which the text will be rendered
* @param Zend_Pdf_Resource_Font $font the font with which the text will be rendered
* @param int $fontSize the font size with which the text will be rendered
* @param int $width [optional] the width for the given text, defaults to the page width
*
* @return array the given text in an array where each item represents a new line
*/
public function _prepareText($text, $page, $font, $fontSize, $width = null)
{
if (empty($text)) {
return array();
}
$lines = '';
$currentLine = '';
// calculate the page's width with respect to the margins
if (empty($width)) {
$width = $page->getWidth() - $this->margin['left'] - ($page->getWidth() - $this->margin['right']);
}
$textChunks = explode(' ', $text);
foreach ($textChunks as $textChunk) {
if ($this->widthForStringUsingFontSize($currentLine . ' ' . $textChunk, $font, $fontSize) < $width) {
// do not add whitespace on first line
if (!empty($currentLine)) {
$currentLine .= ' ';
}
$currentLine .= $textChunk;
} else {
// text is too broad, so add new line character
$lines .= $currentLine . "\n";
$currentLine = $textChunk;
}
}
// append the last line
$lines .= $currentLine;
return explode("\n", $lines);
}
开发者ID:riker09,项目名称:firegento-pdf,代码行数:40,代码来源:Abstract.php
示例19: Zend_Pdf_Page
$page->rotate(0, 0, M_PI_2/3);
$page->saveGS();
$page->clipCircle(550, -10, 50);
$page->drawImage($stampImage, 500, -60, 600, 40);
$page->restoreGS();
$page->drawText('Modified by Zend Framework!', 150, 0);
$page->restoreGS();
}
// Add new page generated by Zend_Pdf object (page is attached to the specified the document)
$pdf->pages[] = ($page1 = $pdf->newPage('A4'));
// Add new page generated by Zend_Pdf_Page object (page is not attached to the document)
$pdf->pages[] = ($page2 = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE));
// Create new font
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// Apply font and draw text
$page1->setFont($font, 36);
$page1->setFillColor(Zend_Pdf_Color_Html::color('#9999cc'));
$page1->drawText('Helvetica 36 text string', 60, 500);
// Use font object for another page
$page2->setFont($font, 24);
$page2->drawText('Helvetica 24 text string', 60, 500);
// Use another font
$page2->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES), 32);
开发者ID:jorgenils,项目名称:zend-framework,代码行数:31,代码来源:demo.php
示例20: drawWaterMask
/**
*
* @param Zend_Pdf_Page $page
* @return void Process drawImage on PDF page
*/
protected function drawWaterMask(&$page)
{
if (Mage::getStoreConfig('advancedinvoiceprinting_options/general/enable') == 0) {
return;
}
$pageWidth = $page->getWidth();
$pageHeight = $page->getHeight();
$image = $this->getImage();
if (is_file($image)) {
/* @var $image Zend_Pdf_Resource_Image */
$image = Zend_Pdf_Image::imageWithPath($image);
$imgWidth = $image->getPixelWidth();
$imgHeight = $image->getPixelHeight();
$percent = Mage::getStoreConfig('advancedinvoiceprinting_options/general/images_size');
$imgWidth = $imgWidth * $percent / 100;
$imgHeight = $imgHeight * $percent / 100;
$x = ($pageWidth - $imgWidth) / 2;
$y = ($pageHeight - $imgHeight) / 2;
if (is_numeric(Mage::getStoreConfig('advancedinvoiceprinting_options/general/offset_x'))) {
$x = $x + (int) Mage::getStoreConfig('advancedinvoiceprinting_options/general/offset_x');
}
if (is_numeric(Mage::getStoreConfig('advancedinvoiceprinting_options/general/offset_y'))) {
$y = $y - (int) Mage::getStoreConfig('advancedinvoiceprinting_options/general/offset_y');
}
$page->drawImage($image, $x, $y, $x + $imgWidth, $y + $imgHeight);
}
}
开发者ID:hyhoocchan,项目名称:extension,代码行数:32,代码来源:Invoice.php
注:本文中的Zend_Pdf_Page类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论