当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Pdf_Font::fontWithPath方法代码示例

本文整理汇总了PHP中Zend_Pdf_Font::fontWithPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Font::fontWithPath方法的具体用法?PHP Zend_Pdf_Font::fontWithPath怎么用?PHP Zend_Pdf_Font::fontWithPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Pdf_Font的用法示例。


在下文中一共展示了Zend_Pdf_Font::fontWithPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 public static function get($font)
 {
     if (empty(Fonts::$loaded[$font])) {
         if (!isset(Fonts::$fonts[$font])) {
             exit('NO FONT SELECTED');
         }
         Fonts::$loaded[$font] = Zend_Pdf_Font::fontWithPath("__fonts/" . Fonts::$fonts[$font]);
     }
     return Fonts::$loaded[$font];
 }
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:10,代码来源:fonts.php

示例2: get

 /**
  * Get or load font
  *
  * @param string $font Font name
  * @return Zend_Pdf_Font Selected font
  */
 public static function get($font)
 {
     if (empty(Model_Static_Fonts::$loaded[$font])) {
         if (!isset(Model_Static_Fonts::$Model_Static_Fonts[$font])) {
             exit('NO FONT SELECTED');
         }
         Model_Static_Fonts::$loaded[$font] = Zend_Pdf_Font::fontWithPath(APPLICATION_ROOT . '/files/pdf/fonts/' . Model_Static_Fonts::$Model_Static_Fonts[$font]);
     }
     return Model_Static_Fonts::$loaded[$font];
 }
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:16,代码来源:PdfPage.php

示例3: _buildPDFDocuments

 protected function _buildPDFDocuments(Doc_Book $book)
 {
     set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/../_vendor/zf');
     $pdf = new Zend_Pdf();
     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     $font = Zend_Pdf_Font::fontWithPath('c:\\windows\\fonts\\simkai.ttf');
     $page->setFont($font, 12);
     $pdf->pages[] = $page;
     $page->drawText('中文测试', 100, 430, 'UTF-8');
     $pdf->save('output.pdf');
 }
开发者ID:Debenson,项目名称:openwan,代码行数:11,代码来源:book.php

示例4: __construct

 public function __construct()
 {
     $this->_page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
     $this->_yPosition = 40;
     $this->_leftMargin = 20;
     $this->_pageHeight = $this->_page->getHeight();
     //842 point
     $this->_pageWidth = $this->_page->getWidth();
     //595 point
     $this->_normalFont = Zend_Pdf_Font::fontWithPath(APPLICATION_PATH . '/templates/admin/fonts/times.ttf');
     $this->_boldFont = Zend_Pdf_Font::fontWithPath(APPLICATION_PATH . '/templates/admin/fonts/timesbd.ttf');
 }
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:12,代码来源:Page.php

示例5: gerarCertificado

 private function gerarCertificado($idEncontro, $array = array())
 {
     // include auto-loader class
     require_once 'Zend/Loader/Autoloader.php';
     // register auto-loader
     $loader = Zend_Loader_Autoloader::getInstance();
     $pdf = new Zend_Pdf();
     $page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
     $font = Zend_Pdf_Font::fontWithPath(APPLICATION_PATH . "/../public/font/UbuntuMono-R.ttf");
     $page1->setFont($font, Sige_Pdf_Certificado::TAM_FONTE);
     // configura o plano de fundo
     $this->background($page1, $idEncontro);
     for ($index = 0; $index < count($array); $index++) {
         $page1->drawText($array[$index], Sige_Pdf_Certificado::POS_X_INICIAL, Sige_Pdf_Certificado::POS_Y_INICIAL - $index * Sige_Pdf_Certificado::DES_Y, 'UTF-8');
     }
     // configura a(s) assinatura(s)
     $this->assinaturas($page1, $idEncontro);
     $pdf->pages[] = $page1;
     // salve apenas em modo debug!
     // $pdf->save(APPLICATION_PATH . '/../tmp/certificado-participante.pdf');
     // Get PDF document as a string
     return $pdf->render();
 }
开发者ID:jovanepires,项目名称:sige,代码行数:23,代码来源:Certificado.php

示例6: _setFontItalic

 /**
  * Set font as italic
  *
  * @param  int $size
  * @return \Zend_Pdf_Resource_Font
  */
 protected function _setFontItalic($size = 7)
 {
     $font = \Zend_Pdf_Font::fontWithPath($this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_It-2.8.2.ttf'));
     $this->getPage()->setFont($font, $size);
     return $font;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:12,代码来源:AbstractItems.php

示例7: inject

function inject($a,$pdfPage,$row,$offsety = 0) {
	global $db,$path;
	foreach($a as $t) {
			switch($t['type']) {
				case 'text':
					$pdfPage
						->setFont($pdfPage->getFont(), $t['fontSize']);
					;
					//alignedText($t,trim(@$row[$t['fieldName']]),$pdfPage,$offsety);
					$fields = explode(",",$t['fieldName']);
					$txt = "";
					foreach($fields as $field) {
						$txt .= $row[$field] . PHP_EOL;
					}
					alignedText($t,$txt,$pdfPage,$offsety);
					
				break;
				case 'cmd':
					switch($t['cmdName']) {
						case 'extratext':
							$pdfPage->setFont($pdfPage->getFont(), $t['fontSize']);
							alignedText($t,$t['extratext'],$pdfPage,$offsety);
						break;
						case 'rotate':
							$pdfPage->rotate(0, 0, deg2rad((float)$t['degrees']));
						break;
						case 'fontSize':
							$pdfPage->setFont($font, (float)$t['fontSize']);
						break;
						case 'font':
							$font = Zend_Pdf_Font::fontWithPath($path.'/fonts/'. $t['typeface'] .'.ttf',Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION); 
							$pdfPage->setFont($font, 12);
						break;
						case 'color':
							$pdfPage->setFillColor(new Zend_Pdf_Color_HTML($t['color']));
						break;
						case 'subReport':
							$subDatFile = "${path}".$t['subReportId'].".dat";
							$result = $db->Query("select * from CustomReport where Id='${t['subReportId']}'");
							if (file_exists($subDatFile)) {
								$sub = unserialize(file_get_contents($subDatFile));
							} else {
								$sub = array(
									array('type'=>'jsonInfo','nextId'=>1,'reportName'=>'CustomPDF','ReportId'=>$t['subReportId'])
								);
							}
							$sub[0] = array_merge($sub[0],$db->GetRow($result));
							//the set of commands is then going to be injected into the current page...
							$r = getQuery($sub,$row['_id']);
							$reportName = $r[1];
							
							$subResult = $db->Query($r[0]);
							$subOffsety = (float)$t['y'];
							while ($subRow = $db->GetRow($subResult)) {
								$subOffsety = inject($sub,$pdfPage,$subRow,$subOffsety);
								$subOffsety += (float)$t['ySize'];
							}
						break;
					}
				break;
			}
		}
	return $offsety;
}
开发者ID:Tetting,项目名称:Shorty,代码行数:64,代码来源:custom.php

示例8: drawLineBlocks

 /**
  * Draw lines
  *
  * Draw items array format:
  * lines        array;array of line blocks (required)
  * shift        int; full line height (optional)
  * height       int;line spacing (default 10)
  *
  * line block has line columns array
  *
  * column array format
  * text         string|array; draw text (required)
  * feed         int; x position (required)
  * font         string; font style, optional: bold, italic, regular
  * font_file    string; path to font file (optional for use your custom font)
  * font_size    int; font size (default 7)
  * align        string; text align (also see feed parametr), optional left, right
  * height       int;line spacing (default 10)
  *
  * @param  \Zend_Pdf_Page $page
  * @param  array $draw
  * @param  array $pageSettings
  * @throws \Magento\Framework\Model\Exception
  * @return \Zend_Pdf_Page
  */
 public function drawLineBlocks(\Zend_Pdf_Page $page, array $draw, array $pageSettings = array())
 {
     foreach ($draw as $itemsProp) {
         if (!isset($itemsProp['lines']) || !is_array($itemsProp['lines'])) {
             throw new \Magento\Framework\Model\Exception(__('We don\'t recognize the draw line data. Please define the "lines" array.'));
         }
         $lines = $itemsProp['lines'];
         $height = isset($itemsProp['height']) ? $itemsProp['height'] : 10;
         if (empty($itemsProp['shift'])) {
             $shift = 0;
             foreach ($lines as $line) {
                 $maxHeight = 0;
                 foreach ($line as $column) {
                     $lineSpacing = !empty($column['height']) ? $column['height'] : $height;
                     if (!is_array($column['text'])) {
                         $column['text'] = array($column['text']);
                     }
                     $top = 0;
                     foreach ($column['text'] as $part) {
                         $top += $lineSpacing;
                     }
                     $maxHeight = $top > $maxHeight ? $top : $maxHeight;
                 }
                 $shift += $maxHeight;
             }
             $itemsProp['shift'] = $shift;
         }
         if ($this->y - $itemsProp['shift'] < 15) {
             $page = $this->newPage($pageSettings);
         }
         foreach ($lines as $line) {
             $maxHeight = 0;
             foreach ($line as $column) {
                 $fontSize = empty($column['font_size']) ? 10 : $column['font_size'];
                 if (!empty($column['font_file'])) {
                     $font = \Zend_Pdf_Font::fontWithPath($column['font_file']);
                     $page->setFont($font, $fontSize);
                 } else {
                     $fontStyle = empty($column['font']) ? 'regular' : $column['font'];
                     switch ($fontStyle) {
                         case 'bold':
                             $font = $this->_setFontBold($page, $fontSize);
                             break;
                         case 'italic':
                             $font = $this->_setFontItalic($page, $fontSize);
                             break;
                         default:
                             $font = $this->_setFontRegular($page, $fontSize);
                             break;
                     }
                 }
                 if (!is_array($column['text'])) {
                     $column['text'] = array($column['text']);
                 }
                 $lineSpacing = !empty($column['height']) ? $column['height'] : $height;
                 $top = 0;
                 foreach ($column['text'] as $part) {
                     if ($this->y - $lineSpacing < 15) {
                         $page = $this->newPage($pageSettings);
                     }
                     $feed = $column['feed'];
                     $textAlign = empty($column['align']) ? 'left' : $column['align'];
                     $width = empty($column['width']) ? 0 : $column['width'];
                     switch ($textAlign) {
                         case 'right':
                             if ($width) {
                                 $feed = $this->getAlignRight($part, $feed, $width, $font, $fontSize);
                             } else {
                                 $feed = $feed - $this->widthForStringUsingFontSize($part, $font, $fontSize);
                             }
                             break;
                         case 'center':
                             if ($width) {
                                 $feed = $this->getAlignCenter($part, $feed, $width, $font, $fontSize);
                             }
//.........这里部分代码省略.........
开发者ID:aiesh,项目名称:magento2,代码行数:101,代码来源:AbstractPdf.php

示例9: getPdf

 public function getPdf($invoices = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     $selected_font = Mage::getStoreConfig('estoreiq_options/messages/estoreiq_font_selected');
     if ($selected_font == 'courier') {
         $the_font = Zend_Pdf_font::fontWithName(Zend_pdf_font::FONT_COURIER);
     } else {
         if ($selected_font == 'times') {
             $the_font = Zend_Pdf_font::fontWithName(Zend_pdf_font::FONT_TIMES);
         } else {
             $the_font = Zend_Pdf_font::fontWithName(Zend_pdf_font::FONT_HELVETICA);
         }
     }
     $pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     //$this->_setFontBold($style, 10);
     foreach ($invoices as $invoice) {
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
         $pdf->pages[] = $page;
         $order = $invoice->getOrder();
         $page->setFont($the_font, 10);
         /* Add image */
         $this->insertLogo($page, $invoice->getStore());
         /* Add address */
         $this->insertAddress($page, $invoice->getStore());
         /* Add head */
         $this->insertOrder($page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId()));
         /* Add image 2 */
         $this->insertLogo2($page, $invoice->getStore());
         $page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
         //$this->_setFontBold($style, 26);
         $page->setFont($the_font, 24);
         $page->drawText('TAX INVOICE (regular invoice)', 335, 580, 'UTF-8');
         /* Add Barcode (custom: Matt Johnson 2008-06-13)*/
         /* convertToBarcodeString resides in extended abstract.php file*/
         $barcodeString = $this->convertToBarcodeString($order->getRealOrderId());
         $page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
         $page->setFont(Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/' . 'Code128bWin.ttf'), 22);
         $qr_code_activated = Mage::getStoreConfig('estoreiq_options/messages/estoreiq_qr_detection_code_enabled');
         if ($qr_code_activated == '1') {
             $page->drawText($barcodeString, 420, 755, 'CP1252');
         }
         $this->y -= 50;
         $page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0));
         $this->_setFontRegular($page);
         //$page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35, 780, 'UTF-8');
         /* 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')->__('Product') . $qr_code_activated, 35, $this->y, 'UTF-8');
         //$page->drawText(Mage::helper('sales')->__('SKU'), 240, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('QTY'), 430, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
         $this->y -= 15;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         /* Add body */
         foreach ($invoice->getAllItems() as $item) {
             if ($item->getOrderItem()->getParentItem()) {
                 continue;
             }
             $shift = array();
             if ($this->y < 15) {
                 /* Add new table head */
                 $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
                 $pdf->pages[] = $page;
                 $this->y = 800;
                 $this->_setFontRegular($page);
                 $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')->__('Product'), 35, $this->y, 'UTF-8');
                 //$page->drawText(Mage::helper('sales')->__('SKU'), 240, $this->y, 'UTF-8');
                 $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
                 $page->drawText(Mage::helper('sales')->__('QTY'), 430, $this->y, 'UTF-8');
                 $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
                 $page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
                 $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                 $this->y -= 20;
             }
             /* Draw item */
             $this->_drawItem($item, $page, $order);
         }
         /* Add totals */
         $this->insertTotals($page, $invoice);
     }
     $this->_afterGetPdf();
     return $pdf;
 }
开发者ID:xiaoguizhidao,项目名称:ecommerce,代码行数:99,代码来源:Invoice.php

示例10: _setFontItalic

 /**
  * Set font as italic
  *
  * @param  int $size
  * @return Zend_Pdf_Resource_Font
  */
 protected function _setFontItalic($size = 7)
 {
     $font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_It-2.8.2.ttf');
     $this->getPage()->setFont($font, $size);
     return $font;
 }
开发者ID:quyip8818,项目名称:Mag,代码行数:12,代码来源:Abstract.php

示例11: drawLineBlocks


//.........这里部分代码省略.........
                             $mh = 50;
                             $ratio = $image->getPixelWidth() / $mw;
                             $w = $image->getPixelWidth() / $ratio;
                             $h = $image->getPixelHeight() / $ratio;
                             if ($h > $mh) {
                                 $ratio = $image->getPixelHeight() / $mh;
                                 $w = $image->getPixelWidth() / $ratio;
                                 $h = $image->getPixelHeight() / $ratio;
                             }
                             $x1 = $column["feed"];
                             $y1 = $this->y - $h + 20;
                             $x2 = $x1 + $w;
                             $y2 = $y1 + $h;
                             $page->drawImage($image, $x1, $y1, $x2, $y2);
                         }
                     }
                 }
                 // type checker
                 if (isset($column["type"])) {
                     if ("check" === $column["type"]) {
                         $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.2));
                         $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
                         // checker one
                         $x1 = $column["feed"];
                         $y1 = $this->y + 25;
                         $x2 = $column["feed"] + 48;
                         $y2 = $this->y - 48 + 25;
                         $page->drawRectangle($x1, $y1, $x2, $y2);
                         //
                         // checker two
                         /*
                         $x1 = $column["feed"] +50;
                         $y1 = $this->y -32;
                         $x2 = $column["feed"] +10 +50;
                         $y2 = $this->y +10 -32;				
                         $page->drawRectangle($x1, $y1, $x2, $y2);
                         			
                                 			$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                         $page->drawText("Für den erneuten Versand der Ware bitte ankreuzen:", 380, $y2 -6, 'UTF-8');
                         */
                         //
                         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                     }
                 }
                 $fontSize = empty($column['font_size']) ? 7 : $column['font_size'];
                 if (!empty($column['font_file'])) {
                     $font = Zend_Pdf_Font::fontWithPath($column['font_file']);
                     $page->setFont($font, $fontSize);
                 } else {
                     $fontStyle = empty($column['font']) ? 'regular' : $column['font'];
                     switch ($fontStyle) {
                         case 'bold':
                             $font = $this->_setFontBold($page, $fontSize);
                             break;
                         case 'italic':
                             $font = $this->_setFontItalic($page, $fontSize);
                             break;
                         default:
                             $font = $this->_setFontRegular($page, $fontSize);
                             break;
                     }
                 }
                 if (!is_array($column['text'])) {
                     $column['text'] = array($column['text']);
                 }
                 $lineSpacing = !empty($column['height']) ? $column['height'] : $height;
                 $top = 0;
                 $antitop = 0;
                 foreach ($column['text'] as $part) {
                     if ($this->y - $lineSpacing < 15) {
                         $page = $this->newPage($pageSettings);
                     }
                     $feed = $column['feed'];
                     $textAlign = empty($column['align']) ? 'left' : $column['align'];
                     $width = empty($column['width']) ? 0 : $column['width'];
                     switch ($textAlign) {
                         case 'right':
                             if ($width) {
                                 $feed = $this->getAlignRight($part, $feed, $width, $font, $fontSize);
                             } else {
                                 $feed = $feed - $this->widthForStringUsingFontSize($part, $font, $fontSize);
                             }
                             break;
                         case 'center':
                             if ($width) {
                                 $feed = $this->getAlignCenter($part, $feed, $width, $font, $fontSize);
                             }
                             break;
                     }
                     $page->drawText($part, $feed, $this->y - $antitop, 'UTF-8');
                     $antitop += 12;
                 }
                 $top += $lineSpacing;
                 $maxHeight = $top > $maxHeight ? $top : $maxHeight;
             }
             $this->y -= $maxHeight;
         }
     }
     return $page;
 }
开发者ID:vberzsin,项目名称:shop,代码行数:101,代码来源:Abstract.php

示例12: getFont

 public function getFont($po_pdf, $ps_fontname, $ps_encoding = 'auto')
 {
     if ($this->getPDFLibrary() == __PDF_LIBRARY_ZEND__) {
         if (isset($this->opa_fonts[$ps_fontname])) {
             return $this->opa_fonts[$ps_fontname];
         }
         $o_font = null;
         // try loading it from configured font dir
         if ($vs_font_dir = $this->opo_config->get('fonts_directory')) {
             if (file_exists($vs_font_dir . '/' . $ps_fontname)) {
                 try {
                     $o_font = Zend_Pdf_Font::fontWithPath($vs_font_dir . '/' . $ps_fontname);
                 } catch (Exception $e) {
                     //noop
                 }
             }
         }
         if (!$o_font) {
             try {
                 $o_font = Zend_Pdf_Font::fontWithName($ps_fontname);
             } catch (Exception $e) {
                 $o_font = Zend_Pdf_Font::fontWithName('Courier');
             }
             $this->opa_fonts[$ps_fontname] = $o_font;
         }
         return $o_font;
     } else {
         if (isset($this->opa_fonts[$ps_fontname])) {
             return $this->opa_fonts[$ps_fontname];
         }
         if ($vn_font = $po_pdf->load_font($ps_fontname, 'winansi', "errorpolicy=return")) {
             return $this->opa_fonts[$ps_fontname] = $vn_font;
         }
         // try loading it from configured font dir
         if ($vs_font_dir = $this->opo_config->get('fonts_directory')) {
             $po_pdf->set_parameter('FontOutline', $ps_fontname . '=' . $vs_font_dir . '/' . $ps_fontname);
             $va_tmp = explode('.', $ps_fontname);
             array_pop($va_tmp);
             $vs_afm_name = join('.', $va_tmp) . '.afm';
             $po_pdf->set_parameter('FontAFM', $ps_fontname . '=' . $vs_font_dir . '/' . $vs_afm_name);
             if ($vn_font = $po_pdf->load_font($ps_fontname, 'winansi', "errorpolicy=return")) {
                 return $this->opa_fonts[$ps_fontname] = $vn_font;
             }
         }
     }
     $this->postError(2260, _t("Could not load font '%1'", $ps_fontname), "PrintForms->getFont()");
     return null;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:48,代码来源:PrintForms.php

示例13: ajaxpdfAction

	public function ajaxpdfAction()
	{
		$this->_helper->layout()->disableLayout();
	//	$this->_helper->viewRenderer->setNoRender(true);
		
		$pdf = new Zend_Pdf();
		$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
		$font = Zend_Pdf_Font::fontWithPath('font/simkai.ttf',(Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION |
Zend_Pdf_Font::EMBED_DONT_COMPRESS));
		//put the personal information to the pdf
		$contacts = new Employee_Models_ContactMapper();
		$arrayContacts = $contacts->fetchAllJoin();
		$count = 1;//every page show approximately 20 pieces;
		//$arrayCount = count($arrayContacts);
		$totalItems = $arrayContacts->getTotalItemCount();
		$arrayContacts->setItemCountPerPage($totalItems);

		$pageNumber = ceil($totalItems / 25);
		$x = 0; $y = 750;
		$currentpage = 1;
		foreach($arrayContacts as $contact)
		{
			if($count == 1)
			{
				$page->setLineWidth(0.5);
				$page->drawLine(50, 770, 560, 770);
				$page->drawLine(50, 125, 560, 125);
				$page->setFont($font,13)
						->drawText("编号", 50, $y, 'UTF-8')
						->drawText("姓名", 100, $y, 'UTF-8')
						->drawText("性别", 145, $y, 'UTF-8')
						->drawText("生日", 195, $y, 'UTF-8')
						->drawText("部门", 275, $y, 'UTF-8')
						->drawText("职务", 335, $y, 'UTF-8')
						->drawText("入职时间", 415, $y, 'UTF-8')
						->drawText("手机号码", 495, $y, 'UTF-8');
				$time = Date("Y-m-d,H:i");
				$users = new System_Models_UserMapper();
				$contactId = $users->getContactId($this->getUserId());
				$contacts = new Employee_Models_ContactMapper();
				$contactName = $contacts->findContactName($contactId);
				$page->setFont($font,11)
						->drawText("公司员工信息总览", 250, 790, 'UTF-8')
						->drawText("导出人:".$contactName, 50, 100, 'UTF-8')
						->drawText("导出日期:".$time, 250, 100, 'UTF-8')
						->drawText("页数:".$currentpage."(".$pageNumber.")", 500, 100, 'UTF-8');
				}
				$y -= 25;$count++;
				$page->setFont($font, 11)
						->drawText($contact->contactId, $x+=50, $y, 'UTF-8')
						->drawText($contact->contactName, $x+=50, $y, 'UTF-8')
						->drawText($contact->gender, $x+=45, $y, 'UTF-8')
						->drawText($contact->birth, $x+=50, $y, 'UTF-8')
						->drawText($contact->deptName, $x+=80, $y, 'UTF-8')
						->drawText($contact->dutyName, $x+=60, $y, 'UTF-8')
						->drawText($contact->enroll, $x+=80, $y, 'UTF-8')
						->drawText($contact->phoneMob, $x+=80, $y, 'UTF-8');
			if($count >= 25)
			{
				$pdf->pages[] = $page;
				$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
				$count = 1;
				$y = 750;
				$currentpage++;
				}
			$x = 0;
			}
		$pdf->pages[] = $page;
		$name_string = "公司员工信息总览".time().".pdf";
		//server
		$base = General_Models_ServerInfo::$localUrl;
		$url = 'tmp/'.$name_string;
		$pdf->save($url);
		$murl = $base.'/'.$url;
		$this->view->murl = $murl;
		}
开发者ID:robliuning,项目名称:Luckyrabbit,代码行数:76,代码来源:IndexController.php

示例14: setFont

 protected function setFont(\Zend_Pdf_Page $page, $size = 12)
 {
     $basePath = APPLICATION_PATH . "/../public/fonts/";
     $font = \Zend_Pdf_Font::fontWithPath($basePath . 'LiberationSans-Regular.ttf');
     $page->setFont($font, $size);
 }
开发者ID:sp1ke77,项目名称:MLM-1,代码行数:6,代码来源:Creator.php

示例15: testFontDrawing

 public function testFontDrawing()
 {
     $pdf = new Zend_Pdf();
     $fontsList = array(Zend_Pdf_Font::FONT_COURIER, Zend_Pdf_Font::FONT_COURIER_BOLD, Zend_Pdf_Font::FONT_COURIER_BOLD_ITALIC, Zend_Pdf_Font::FONT_COURIER_BOLD_OBLIQUE, Zend_Pdf_Font::FONT_COURIER_ITALIC, Zend_Pdf_Font::FONT_COURIER_OBLIQUE, Zend_Pdf_Font::FONT_HELVETICA, Zend_Pdf_Font::FONT_HELVETICA_BOLD, Zend_Pdf_Font::FONT_HELVETICA_BOLD_ITALIC, Zend_Pdf_Font::FONT_HELVETICA_BOLD_OBLIQUE, Zend_Pdf_Font::FONT_HELVETICA_ITALIC, Zend_Pdf_Font::FONT_HELVETICA_OBLIQUE, Zend_Pdf_Font::FONT_TIMES, Zend_Pdf_Font::FONT_TIMES_BOLD, Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC, Zend_Pdf_Font::FONT_TIMES_ITALIC, Zend_Pdf_Font::FONT_TIMES_ROMAN);
     $titleFont = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER_BOLD_OBLIQUE);
     foreach ($fontsList as $fontName) {
         // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
         $pdf->pages[] = $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
         $font = Zend_Pdf_Font::fontWithName($fontName);
         $this->assertTrue($font instanceof Zend_Pdf_Resource_Font);
         $page->setFont($titleFont, 10);
         $page->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en') . ':', 100, 400);
         $page->setFont($font, 20);
         $page->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360);
         $ascent = $font->getAscent();
         $this->assertTrue(abs(1 - $font->getCoveredPercentage('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxwz')) < 1.0E-5);
         $descent = $font->getDescent();
         $font->getFontName(Zend_Pdf_Font::NAME_FULL, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_FAMILY, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_FAMILY, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_STYLE, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_STYLE, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_DESCRIPTION, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_SAMPLE_TEXT, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_ID, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_VERSION, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_CID_NAME, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER_URL, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_MANUFACTURER, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_VENDOR_URL, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_COPYRIGHT, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_TRADEMARK, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_LICENSE, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_LICENSE_URL, 'en');
         $type = $font->getFontType();
         $lineGap = $font->getLineGap();
         $lineHeight = $font->getLineHeight();
         $this->assertTrue($font->getResource() instanceof Zend_Pdf_Element_Object);
         $font->getStrikePosition();
         $font->getStrikeThickness();
         $font->getUnderlinePosition();
         $font->getUnitsPerEm();
         $font->widthForGlyph(10);
     }
     $nonAlphabeticalPhonts = array(Zend_Pdf_Font::FONT_SYMBOL => " !\"#\"%&\"\v()\"+,\"./0123456789:;<=>?\"E‘’§\"•¦", Zend_Pdf_Font::FONT_ZAPFDINGBATS => " ''''&''''\t&&'\f'\r'''''''''''''");
     foreach ($nonAlphabeticalPhonts as $fontName => $example) {
         // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
         $pdf->pages[] = $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
         $font = Zend_Pdf_Font::fontWithName($fontName);
         $this->assertTrue($font instanceof Zend_Pdf_Resource_Font);
         $page->setFont($titleFont, 10);
         $page->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en') . ':', 100, 400);
         $page->setFont($font, 20);
         $page->drawText($example, 100, 360, 'UTF-16BE');
         $ascent = $font->getAscent();
         $this->assertTrue(abs(1 - $font->getCoveredPercentage($example, 'UTF-16BE')) < 1.0E-5);
         $descent = $font->getDescent();
         $font->getFontName(Zend_Pdf_Font::NAME_FULL, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_FAMILY, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_FAMILY, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_STYLE, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_PREFERRED_STYLE, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_DESCRIPTION, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_SAMPLE_TEXT, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_ID, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_VERSION, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_CID_NAME, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_DESIGNER_URL, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_MANUFACTURER, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_VENDOR_URL, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_COPYRIGHT, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_TRADEMARK, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_LICENSE, 'en');
         $font->getFontName(Zend_Pdf_Font::NAME_LICENSE_URL, 'en');
         $type = $font->getFontType();
         $lineGap = $font->getLineGap();
         $lineHeight = $font->getLineHeight();
         $this->assertTrue($font->getResource() instanceof Zend_Pdf_Element_Object);
         $font->getStrikePosition();
         $font->getStrikeThickness();
         $font->getUnderlinePosition();
         $font->getUnitsPerEm();
         $font->widthForGlyph(10);
     }
     $TTFFontsList = array('VeraBd.ttf', 'VeraBI.ttf', 'VeraIt.ttf', 'VeraMoBd.ttf', 'VeraMoBI.ttf', 'VeraMoIt.ttf', 'VeraMono.ttf', 'VeraSeBd.ttf', 'VeraSe.ttf', 'Vera.ttf');
     foreach ($TTFFontsList as $fontName) {
         // Add new page generated by Zend_Pdf object (page is attached to the specified the document)
         $pdf->pages[] = $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
         $font = Zend_Pdf_Font::fontWithPath(dirname(__FILE__) . '/_fonts/' . $fontName);
         $this->assertTrue($font instanceof Zend_Pdf_Resource_Font);
         $page->setFont($titleFont, 10);
         $page->drawText($font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en') . ':', 100, 400);
         $page->setFont($font, 20);
         $page->drawText("'The quick brown fox jumps over the lazy dog'", 100, 360);
         $ascent = $font->getAscent();
         $this->assertTrue(abs(1 - $font->getCoveredPercentage('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxwz')) < 1.0E-5);
//.........这里部分代码省略.........
开发者ID:jorgenils,项目名称:zend-framework,代码行数:101,代码来源:DrawingTest.php


注:本文中的Zend_Pdf_Font::fontWithPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。