本文整理汇总了PHP中Zend_Pdf_Page::getFont方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Page::getFont方法的具体用法?PHP Zend_Pdf_Page::getFont怎么用?PHP Zend_Pdf_Page::getFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Pdf_Page
的用法示例。
在下文中一共展示了Zend_Pdf_Page::getFont方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: _drawSenderAddress
/**
* Draw Sender Address
*
* @param SimpleXMLElement $addressLines
* @param string $phoneNumber
* @return float
* @throws Zend_Pdf_Exception
*/
protected function _drawSenderAddress(SimpleXMLElement $addressLines, $phoneNumber)
{
$lines = array();
foreach ($addressLines as $line) {
$lines[] = $line;
}
$pageY = 0;
if (strlen($lines[0]) > 28) {
$firstLine = array_shift($lines);
$pageY = $this->_page->drawLines(array($firstLine), $this->_x(25), $this->_y(42), 28);
$this->_page->drawText($phoneNumber, $this->_x(103), $this->_y(42));
} else {
$pageY = $this->_y(42);
$lineLength = $this->_page->getTextWidth($lines[0] . ' ', $this->_page->getFont(), $this->_page->getFontSize());
$this->_page->drawText($phoneNumber, $this->_x(25 + $lineLength), $this->_y(42));
}
return $this->_page->drawLines($lines, $this->_x(25), $pageY, 49);
}
示例3: _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
示例4: _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');
}
}
return $page;
}
示例5: getTextWidth
/**
* Calculate text width
*
* @param string $text
* @param Zend_Pdf_Page|Zend_Pdf_Resource_Font $resource
* @param int $fontSize
* @param string $encoding
* @return double
*/
public function getTextWidth($text, $resource, $fontSize = null, $encoding = 'UTF-8')
{
if ($resource instanceof Zend_Pdf_Page) {
$font = $resource->getFont();
$fontSize = $resource->getFontSize();
} elseif ($resource instanceof Zend_Pdf_Resource_Font) {
$font = $resource;
if ($fontSize === null) {
throw new Exception('The fontsize is unknown');
}
}
if (!$font instanceof Zend_Pdf_Resource_Font) {
throw new Exception('Invalid resource passed');
}
//$drawingText = iconv ( '', $encoding, $text );
$drawingText = $text;
$characters = array();
for ($i = 0; $i < strlen($drawingText); $i++) {
$characters[] = ord($drawingText[$i]);
}
$glyphs = $font->glyphNumbersForCharacters($characters);
$widths = $font->widthsForGlyphs($glyphs);
$textWidth = array_sum($widths) / $font->getUnitsPerEm() * $fontSize;
return $textWidth;
}
示例6: count
if (!file_exists($reportPath.$doc)) {
$pdf = new Zend_Pdf();
$pdf->pages[] = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$page = $pdf->pages[0];
} else {
$pdf = Library_Pdf_Base::load($reportPath.$doc);
$templatePage = count($pdf->pages)-1;
$page = new Zend_Pdf_Page($pdf->pages[$templatePage]);
unset($pdf->pages[$templatePage]);
$pdf->pages[] = $page;
}
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 20);
$page->setFont($page->getFont(), 12); include("$easyDBDir/easyDB.php");
include("$easyDBDir/easyDBConn2.php");
$db = easyDB('');
//process parameters.
$id = $_REQUEST['id'];
$query="Select
Fadderbarn.*
,Giver.*
,Giver.ZipTown || ' ' || Giver.ZipCode as 'Giver.Post'
From
Fadderbarn
,Giver
Where
Giver.Id = Fadderbarn.GiverId
AND Fadderbarn.Id = '$id'";
示例7: _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');
}
}