本文整理汇总了PHP中Zend_Pdf_Font类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Font类的具体用法?PHP Zend_Pdf_Font怎么用?PHP Zend_Pdf_Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Pdf_Font类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getPdf
/**
* Creates a PDF report from the Minutes model given.
* Returns the PDF as a string that can either be saved to disk
* or streamed back to the browser.
*
* @param Phprojekt_Model_Interface $minutesModel The minutes model object to create the PDF from.
*
* @return string The resulting PDF document.
*/
public static function getPdf(Phprojekt_Model_Interface $minutesModel)
{
$phpr = Phprojekt::getInstance();
$pdf = new Zend_Pdf();
$page = new Phprojekt_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$pages = array($page);
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
$page->setBorder(2.0 * Phprojekt_Pdf_Page::PT_PER_CM, 2.0 * Phprojekt_Pdf_Page::PT_PER_CM, 2.0 * Phprojekt_Pdf_Page::PT_PER_CM, 3.0 * Phprojekt_Pdf_Page::PT_PER_CM);
$page->addFreetext(array('lines' => $minutesModel->title, 'fontSize' => 20));
$page->addFreetext(array('lines' => array_merge(explode("\n\n", $minutesModel->description), array($phpr->translate('Start') . ': ' . $minutesModel->meetingDatetime, $phpr->translate('End') . ': ' . $minutesModel->endTime, $phpr->translate('Place') . ': ' . $minutesModel->place, $phpr->translate('Moderator') . ': ' . $minutesModel->moderator)), 'fontSize' => 12));
$invited = Minutes_Helpers_Userlist::expandIdList($minutesModel->participantsInvited);
$attending = Minutes_Helpers_Userlist::expandIdList($minutesModel->participantsAttending);
$excused = Minutes_Helpers_Userlist::expandIdList($minutesModel->participantsExcused);
$pages += $page->addTable(array('fontSize' => 12, 'rows' => array(array(array('text' => $phpr->translate('Invited'), 'width' => 4.7 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => array_reduce($invited, array('self', '_concat')), 'width' => 12.0 * Phprojekt_Pdf_Page::PT_PER_CM)), array(array('text' => $phpr->translate('Attending'), 'width' => 4.7 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => array_reduce($attending, array('self', '_concat')), 'width' => 12.0 * Phprojekt_Pdf_Page::PT_PER_CM)), array(array('text' => $phpr->translate('Excused'), 'width' => 4.7 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => array_reduce($excused, array('self', '_concat')), 'width' => 12.0 * Phprojekt_Pdf_Page::PT_PER_CM)))));
$page = end($pages);
$itemtable = array();
$items = $minutesModel->items->fetchAll();
foreach ($items as $item) {
$itemtable[] = array(array('text' => $item->topicId, 'width' => 1.3 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $phpr->translate($item->information->getTopicType($item->topicType)), 'width' => 3.0 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $item->getDisplay(), 'width' => 12.4 * Phprojekt_Pdf_Page::PT_PER_CM));
}
$pages += $page->addTable(array('fontSize' => 12, 'rows' => array_merge(array(array('isHeader' => true, array('text' => $phpr->translate('No.'), 'width' => 1.3 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $phpr->translate('Type'), 'width' => 3.0 * Phprojekt_Pdf_Page::PT_PER_CM), array('text' => $phpr->translate('Item'), 'width' => 12.4 * Phprojekt_Pdf_Page::PT_PER_CM))), $itemtable)));
$page = end($pages);
$pdf->pages = $pages;
$pdf->properties['Title'] = $minutesModel->title;
$owner = Minutes_Helpers_Userlist::expandIdList($minutesModel->ownerId);
$pdf->properties['Author'] = $owner[0]['display'];
$pdf->properties['Producer'] = 'PHProjekt version ' . Phprojekt::getVersion();
$pdf->properties['CreationDate'] = 'D:' . gmdate('YmdHis');
$pdf->properties['Keywords'] = $minutesModel->description;
return $pdf->render();
}
开发者ID:penSecIT,项目名称:PHProjekt,代码行数:40,代码来源:Pdf.php
示例2: 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');
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:60,代码来源:DrawingTest.php
示例3: getWrappedText
public function getWrappedText($string, $max_width, $font = '', $fontsize = 14)
{
$font = Zend_Pdf_Font::fontWithName($font);
$wrappedText = '';
$nLines = 1;
$lines = explode("\n", $string);
foreach ($lines as $line) {
$words = explode(' ', $line);
$word_count = count($words);
$i = 0;
$wrappedLine = '';
while ($i < $word_count) {
/* if adding a new word isn't wider than $max_width,
we add the word */
if ($this->widthForStringUsingFontSize($wrappedLine . ' ' . $words[$i], $font, $fontsize) < $max_width) {
if (!empty($wrappedLine)) {
$wrappedLine .= ' ';
}
$wrappedLine .= $words[$i];
} else {
$wrappedText .= $wrappedLine . "\n";
$nLines++;
$wrappedLine = $words[$i];
}
$i++;
}
$wrappedText .= $wrappedLine . "\n";
}
return array('text' => $wrappedText, 'n' => $nLines);
}
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:30,代码来源:Pdf.php
示例4: process
public function process()
{
$configuracao = Doctrine::getTable('Configuracao')->find(1);
$this->document->pages[] = $page = $this->document->newPage(\Zend_Pdf_Page::SIZE_A4);
//monta o cabecalho
$color = array();
$color["black"] = new Zend_Pdf_Color_Html("#000000");
$fontTitle = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES_BOLD);
$size = 12;
$styleTitle = new Zend_Pdf_Style();
$styleTitle->setFont($fontTitle, $size);
$styleTitle->setFillColor($color["black"]);
$page->setStyle($styleTitle);
$page->drawText($configuracao->instituicao, Documento::DOCUMENT_LEFT, Documento::DOCUMENT_TOP, 'UTF-8');
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
$style = new Zend_Pdf_Style();
$style->setFont($font, $size);
$style->setFillColor($color["black"]);
$page->setStyle($style);
$text = wordwrap($this->text, 95, "\n", false);
$token = strtok($text, "\n");
$y = 665;
while ($token != false) {
if ($y < 100) {
$this->document->pages[] = $page = $this->document->newPage(Zend_Pdf_Page::SIZE_A4);
$page->setStyle($style);
$y = 665;
} else {
$y -= 15;
}
$page->drawText($token, 60, $y, 'UTF-8');
$token = strtok("\n");
}
}
开发者ID:kidh0,项目名称:TCControl,代码行数:34,代码来源:AlunosMatriculadosDoc.class.php
示例5: verPdfAction
public function verPdfAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$producto = $this->_producto->getDetalle($this->_getParam('id'));
// var_dump($producto);exit;
$pdf = new Zend_Pdf();
$pdf1 = Zend_Pdf::load(APPLICATION_PATH . '/../templates/producto.pdf');
// $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4); // 595 x842
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// $pdf->pages[] = $page;
// $page->setFont($font, 20);$page->drawText('Zend: PDF', 10, 822);
// $page->setFont($font, 12);$page->drawText('Comentarios', 10, 802);
// $pdfData = $pdf->render();
$page = $pdf1->pages[0];
$page->setFont($font, 12);
$page->drawText($producto['producto'], 116, 639);
$page->drawText($producto['precio'], 116, 607);
$page->drawText($producto['categoria'], 116, 575);
$page->drawText($producto['fabricante'], 116, 543);
$page->drawText('zEND', 200, 200);
$pdfData = $pdf1->render();
header("Content-type: application/x-pdf");
header("Content-Disposition: inline; filename=result.pdf");
$this->_response->appendBody($pdfData);
}
开发者ID:helmutpacheco,项目名称:ventas,代码行数:26,代码来源:ProductoController.php
示例6: _setFontItalic
protected function _setFontItalic($object, $size = 7)
{
if (!$this->getUseFont()) {
return parent::_setFontItalic($object, $size);
}
$font = Zend_Pdf_Font::fontWithName(constant('Zend_Pdf_Font::FONT_' . $this->getUseFont() . '_ITALIC'));
$object->setFont($font, $size);
return $font;
}
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:9,代码来源:Shipment.php
示例7: setStyle
public function setStyle()
{
$style = new Zend_Pdf_Style();
$style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
$style->setFillColor(new Zend_Pdf_Color_Html('#333333'));
$style->setLineColor(new Zend_Pdf_Color_Html('#990033'));
$style->setLineWidth(1);
$this->_page->setStyle($style);
}
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:9,代码来源:Page.php
示例8: 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
示例9: __construct
public function __construct()
{
$this->_page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
$this->_yPosition = 60;
$this->_leftMargin = 50;
$this->_pageHeight = $this->_page->getHeight();
$this->_pageWidth = $this->_page->getWidth();
$this->_normalFont = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
$this->_boldFont = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
}
开发者ID:ramonjmz,项目名称:prosalud,代码行数:10,代码来源:Page.php
示例10: _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
示例11: generateSignupSheet
/**
* Generates the signup sheet for the given event
*
* @param $event
*/
public function generateSignupSheet($event)
{
/**
* Calculate how many pages are needed
*/
$entriesPerPage = 37;
$pageCount = ceil(count($event['attendeeList']) / $entriesPerPage);
/*
* Set up the offsets for the three columns (first, last, signature)
*/
$this->_offsets['columnLeft'] = 45;
$this->_offsets['columnMiddle'] = 150;
$this->_offsets['columnRight'] = 250;
/**
* Fill each page with user information
*/
for ($i = 0; $i < $pageCount; $i++) {
$page = $this->_pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
$this->_pdf->pages[] = $page;
$lineCounter = 0;
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 9);
$page->drawText('Page ' . ($i + 1) . ' of ' . $pageCount, $this->_offsets['right'] - 40, $this->_offsets['top']);
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12);
$page->drawText($event['workshopTitle'], $this->center($event['workshopTitle']), $this->getLineOffset($lineCounter++));
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
$page->drawText($event['location'], $this->center($event['location']), $this->getLineOffset($lineCounter++));
$date = new DateTime($event['date']);
$startTime = new DateTime($event['startTime']);
$endTime = new DateTime($event['endTime']);
$dateString = $date->format('l, M d, Y') . '(' . $startTime->format('g:i A') . ' - ' . $endTime->format('g:i A') . ')';
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
$page->drawText($dateString, $this->center($dateString), $this->getLineOffset($lineCounter++));
$instructorString = 'Instructor' . (count($event['instructors']) > 1 ? 's' : '') . ': ' . implode(', ', $event['instructors']);
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
$page->drawText($instructorString, $this->center($instructorString), $this->getLineOffset($lineCounter++));
$lineCounter += 2;
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 12);
$page->drawText('First Name', $this->_offsets['columnLeft'], $this->getLineOffset($lineCounter));
$page->drawText('Last Name', $this->_offsets['columnMiddle'], $this->getLineOffset($lineCounter));
$page->drawText('Signature', $this->_offsets['columnRight'], $this->getLineOffset($lineCounter));
$lineCounter++;
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
$attendeeList = array_slice($event['attendeeList'], $i * $entriesPerPage, $entriesPerPage);
foreach ($attendeeList as $a) {
$page->drawText($a['firstName'], $this->_offsets['columnLeft'], $this->getLineOffset($lineCounter));
$page->drawText($a['lastName'], $this->_offsets['columnMiddle'], $this->getLineOffset($lineCounter));
$page->drawLine($this->_offsets['columnRight'], $this->getLineOffset($lineCounter) - 2, $this->_offsets['right'], $this->getLineOffset($lineCounter) - 2);
$lineCounter++;
}
}
return $this->_pdf->render();
}
开发者ID:ncsuwebdev,项目名称:classmate,代码行数:57,代码来源:EventPdf.php
示例12: stringWidth
function stringWidth($string, $fontName = PdfContext::fontHelvetica, $fontSize = 12)
{
$font = Zend_Pdf_Font::fontWithName($fontName);
$drawingString = iconv('', 'UTF-16BE', $string);
$characters = array();
for ($i = 0; $i < strlen($drawingString); $i++) {
$characters[] = ord($drawingString[$i++]) << 8 | ord($drawingString[$i]);
}
$glyphs = $font->cmap->glyphNumbersForCharacters($characters);
$widths = $font->widthsForGlyphs($glyphs);
$stringWidth = array_sum($widths) / $font->getUnitsPerEm() * $fontSize;
return $stringWidth;
}
开发者ID:laiello,项目名称:zoop,代码行数:13,代码来源:ZendPdfContext.php
示例13: drawTableHeader
/**
* Dessine l'entete du tableau avec la liste des produits
*
* @param unknown_type $page
*/
public function drawTableHeader(&$page)
{
//entetes de colonnes
$this->y -= 15;
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 12);
$page->drawText(mage::helper('purchase')->__('Qty'), 15, $this->y, 'UTF-8');
$page->drawText(mage::helper('purchase')->__('Manufacturer'), 70, $this->y, 'UTF-8');
$page->drawText(mage::helper('purchase')->__('Sku'), 180, $this->y, 'UTF-8');
$page->drawText(mage::helper('purchase')->__('Product'), 310, $this->y, 'UTF-8');
//barre grise fin entete colonnes
$this->y -= 8;
$page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
$this->y -= 15;
}
开发者ID:TrygveSkogsholm,项目名称:Magento-Patch,代码行数:19,代码来源:SelectedOrdersProductsSummaryPdf.php
示例14: generateAction
public function generateAction()
{
// Create new PDF document.
$pdf = new Zend_Pdf();
// 421 x 596 = A5 Landscape in pixels @ 72dpi
$pdf->pages[] = new Zend_Pdf_Page(596, 421);
$pdf->pages[] = new Zend_Pdf_Page(596, 421);
$front = $pdf->pages[0];
$back = $pdf->pages[1];
// Create new font
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// Apply font
$front->setFont($font, 18);
// Start at the top
$y = 590;
// With a left Margin of 10
$x = 10;
$front->drawText($this->recipe->name, $x, $y);
$y = $y - 30;
$front->setFont($font, 12);
$front->drawText('Difficulty: ' . $this->recipe->difficulty, $x, $y);
$y = $y - 15;
$front->drawText('Preparation Time: ' . $this->recipe->preparation_time, $x, $y);
$y = $y - 15;
$front->drawText('Cooking Time: ' . $this->recipe->preparation_time, $x, $y);
$y = $y - 15;
$front->drawText('Serves: ' . $this->recipe->serves, $x, $y);
$y = $y - 15;
$front->drawText('Freezable: ' . $this->recipe->freezable, $x, $y);
$ingredients = $this->recipe->findRecipeIngredient();
$y = $y - 15;
foreach ($ingredients as $ingredient) {
$y = $y - 15;
$text = '';
if ($ingredient->quantity > 0) {
$text .= $ingredient->quantity;
}
if ($ingredient->amount > 0) {
$text .= $ingredient->amount . ' ';
}
if (!empty($ingredient->measurement)) {
$text .= $ingredient->measurement_abbr . ' ';
}
$text .= $ingredient->name;
$front->drawText($text, $x, $y);
}
$back->setFont($font, 18);
$pdf->save('pdf/foo.pdf');
}
开发者ID:vishaleyes,项目名称:cookingwithzend,代码行数:49,代码来源:PdfController.php
示例15: __construct
public function __construct($labels = array())
{
$cols = null;
foreach ($labels as $label) {
$col = new Core_Pdf_Table_Column();
$col->setText($label);
$cols[] = $col;
}
if ($cols) {
$this->setColumns($cols);
}
//set default alignment
$this->_align = Core_Pdf::CENTER;
//set default borders
$style = new Zend_Pdf_Style();
$style->setLineWidth(2);
$this->setBorder(Core_Pdf::BOTTOM, $style);
$this->setCellPaddings(array(5, 5, 5, 5));
//set default font
$this->_font = Zend_Pdf_Font::fontWithName(ZEND_Pdf_Font::FONT_HELVETICA_BOLD);
$this->_fontSize = 12;
}
开发者ID:uglide,项目名称:zfcore-transition,代码行数:22,代码来源:HeaderRow.php
示例16: generateReport
/**
* Creates and generates the PDF report for the items in the report.
*
* @param string $filePath The path to the zip that contains the generated
* PDFs.
*/
public function generateReport($filePath)
{
if (!extension_loaded('zip')) {
throw new RuntimeException("zip extension is required to bundle " . "report PDF files.");
}
$options = unserialize($this->_reportFile->options);
$this->_baseUrl = $options['baseUrl'];
$this->_font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
$fileSuffix = 1;
$pdfPath = $this->_newPdf($filePath, $fileSuffix);
while ($items = $this->_getItems()) {
if ($this->_pdfPageCount >= $this->_pagesPerFile) {
$fileSuffix++;
$pdfPath = $this->_newPdf($filePath, $fileSuffix);
_log("Created new PDF file '{$pdfPath}'");
$this->_pdfPageCount = 0;
}
$this->_addItems($items, $pdfPath);
}
$this->_zipFiles($filePath);
$this->_unlinkFiles();
return $filePath;
}
开发者ID:ungc0,项目名称:comp356-mac15,代码行数:29,代码来源:PdfQrCode.php
示例17: 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
示例18: getPdf
public function getPdf($orders = array())
{
$this->_beforeGetPdf();
$this->_initRenderer('invoice');
//on cree le pdf que si il n'est pas déja défini( ca permet de mettre plrs documents dans le mm pdf (genre une facture, un BL ....)
$this->pdf = new Zend_Pdf();
$style = new Zend_Pdf_Style();
$style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 10);
//cree la nouvelle page
$titre = mage::helper('purchase')->__('Order Comments');
$settings = array();
$settings['title'] = $titre;
$settings['store_id'] = 0;
$page = $this->NewPage($settings);
$this->y -= $this->_ITEM_HEIGHT * 2;
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0.2));
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
//Rajoute les commandes avec commentaires
foreach ($orders as $order) {
$comments = mage::helper('Organizer')->getEntityCommentsSummary('order', $order->getorder_id(), false);
if ($comments != '') {
$realOrder = mage::getModel('sales/order')->load($order->getorder_id());
$page->drawText(mage::helper('purchase')->__('Order # ') . $realOrder->getIncrementId(), 15, $this->y, 'UTF-8');
$comments = $this->WrapTextToWidth($page, $comments, 450);
$offset = $this->DrawMultilineText($page, $comments, 150, $this->y, 10, 0.2, 11);
$this->y -= 8 + $offset;
$page->drawLine(10, $this->y, $this->_BLOC_ENTETE_LARGEUR, $this->y);
$this->y -= 15;
}
}
//dessine le pied de page
$this->drawFooter($page);
//rajoute la pagination
$this->AddPagination($this->pdf);
$this->_afterGetPdf();
return $this->pdf;
}
开发者ID:TrygveSkogsholm,项目名称:Magento-Patch,代码行数:37,代码来源:SelectedOrdersComments.php
示例19: __construct
/**
* Object constructor
*
* $fontDictionary is a Zend_Pdf_Element_Reference or Zend_Pdf_Element_Object object
*
* @param mixed $fontDictionary
* @throws Zend_Pdf_Exception
*/
public function __construct($fontDictionary)
{
// Extract object factory and resource object from font dirctionary object
$this->_objectFactory = $fontDictionary->getFactory();
$this->_resource = $fontDictionary;
if ($fontDictionary->Encoding !== null) {
$this->_encoding = $fontDictionary->Encoding->value;
}
switch ($fontDictionary->Subtype->value) {
case 'Type0':
// Composite type 0 font
if (count($fontDictionary->DescendantFonts->items) != 1) {
// Multiple descendant fonts are not supported
//$1 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(self::TYPE_NOT_SUPPORTED);
}
$fontDictionaryIterator = $fontDictionary->DescendantFonts->items->getIterator();
$fontDictionaryIterator->rewind();
$descendantFont = $fontDictionaryIterator->current();
$fontDescriptor = $descendantFont->FontDescriptor;
break;
case 'Type1':
if ($fontDictionary->FontDescriptor === null) {
// That's one of the standard fonts
$standardFont = Zend_Pdf_Font::fontWithName($fontDictionary->BaseFont->value);
$this->_fontNames = $standardFont->getFontNames();
$this->_isBold = $standardFont->isBold();
$this->_isItalic = $standardFont->isItalic();
$this->_isMonospace = $standardFont->isMonospace();
$this->_underlinePosition = $standardFont->getUnderlinePosition();
$this->_underlineThickness = $standardFont->getUnderlineThickness();
$this->_strikePosition = $standardFont->getStrikePosition();
$this->_strikeThickness = $standardFont->getStrikeThickness();
$this->_unitsPerEm = $standardFont->getUnitsPerEm();
$this->_ascent = $standardFont->getAscent();
$this->_descent = $standardFont->getDescent();
$this->_lineGap = $standardFont->getLineGap();
return;
}
$fontDescriptor = $fontDictionary->FontDescriptor;
break;
case 'TrueType':
$fontDescriptor = $fontDictionary->FontDescriptor;
break;
default:
//$1 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(self::TYPE_NOT_SUPPORTED);
}
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] = iconv('UTF-8', 'UTF-16BE', $fontDictionary->BaseFont->value);
$this->_isBold = false;
// this property is actually not used anywhere
$this->_isItalic = ($fontDescriptor->Flags->value & 1 << 6) != 0;
// Bit-7 is set
$this->_isMonospace = ($fontDescriptor->Flags->value & 1 << 0) != 0;
// Bit-1 is set
$this->_underlinePosition = null;
// Can't be extracted
$this->_underlineThickness = null;
// Can't be extracted
$this->_strikePosition = null;
// Can't be extracted
$this->_strikeThickness = null;
// Can't be extracted
$this->_unitsPerEm = null;
// Can't be extracted
$this->_ascent = $fontDescriptor->Ascent->value;
$this->_descent = $fontDescriptor->Descent->value;
$this->_lineGap = null;
// Can't be extracted
}
开发者ID:netconstructor,项目名称:Centurion,代码行数:78,代码来源:Extracted.php
示例20: fontWithPath
/**
* Returns a {@link Zend_Pdf_Resource_Font} object by file path.
*
* The result of this method is cached, preventing unnecessary duplication
* of font objects. Repetitive calls for the font with the same path will
* return the same object.
*
* The $embeddingOptions parameter allows you to set certain flags related
* to font embedding. You may combine options by OR-ing them together. See
* the EMBED_ constants defined in {@link Zend_Pdf_Font} for the list of
* available options and their descriptions. Note that this value is only
* used when creating a font for the first time. If a font with the same
* name already exists, you will get that object and the options you specify
* here will be ignored. This is because fonts are only embedded within the
* PDF file once.
*
* If the file path supplied does not match the path of a previously
* instantiated object or the font type cannot be determined, an exception
* will be thrown.
*
* @param string $filePath Full path to the font file.
* @param integer $embeddingOptions (optional) Options for font embedding.
* @return Zend_Pdf_Resource_Font
* @throws Zend_Pdf_Exception
*/
public static function fontWithPath($filePath, $embeddingOptions = 0)
{
/* First check the cache. Don't duplicate font objects.
*/
$filePathKey = md5($filePath);
if (isset(Zend_Pdf_Font::$_fontFilePaths[$filePathKey])) {
return Zend_Pdf_Font::$_fontFilePaths[$filePathKey];
}
/* Create a file parser data source object for this file. File path and
* access permission checks are handled here.
*/
$dataSource = new Zend_Pdf_FileParserDataSource_File($filePath);
/* Attempt to determine the type of font. We can't always trust file
* extensions, but try that first since it's fastest.
*/
$fileExtension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
/* If it turns out that the file is named improperly and we guess the
* wrong type, we'll get null instead of a font object.
*/
switch ($fileExtension) {
case 'ttf':
$font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
break;
default:
/* Unrecognized extension. Try to determine the type by actually
* parsing it below.
*/
$font = null;
break;
}
if ($font === null) {
/* There was no match for the file extension or the extension was
* wrong. Attempt to detect the type of font by actually parsing it.
* We'll do the checks in order of most likely format to try to
* reduce the detection time.
*/
// OpenType
// TrueType
if ($font === null && $fileExtension != 'ttf') {
$font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
}
// Type 1 PostScript
// Mac OS X dfont
// others?
}
/* Done with the data source object.
*/
$dataSource = null;
if ($font !== null) {
/* Parsing was successful. Add this font instance to the cache arrays
* and return it for use.
*/
$fontName = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, '', '');
Zend_Pdf_Font::$_fontNames[$fontName] = $font;
$filePathKey = md5($filePath);
Zend_Pdf_Font::$_fontFilePaths[$filePathKey] = $font;
return $font;
} else {
/* The type of font could not be determined. Give up.
*/
throw new Zend_Pdf_Exception("Cannot determine font type: {$filePath}", Zend_Pdf_Exception::CANT_DETERMINE_FONT_TYPE);
}
}
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:88,代码来源:Font.php
注:本文中的Zend_Pdf_Font类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论