• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Pdf类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getPdf

 public function getPdf($creditmemos = array())
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('creditmemo');
     $pdf = new Zend_Pdf();
     $style = new Zend_Pdf_Style();
     $this->_setFontBold($style, 10);
     foreach ($creditmemos as $creditmemo) {
         $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
         $pdf->pages[] = $page;
         $order = $creditmemo->getOrder();
         /* Add image */
         $this->insertLogo($page, $creditmemo->getStore());
         /* Add address */
         $this->insertAddress($page, $creditmemo->getStore());
         /* Add head */
         $this->insertOrder($page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_CREDITMEMO_PUT_ORDER_ID, $order->getStoreId()));
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
         $this->_setFontRegular($page);
         $page->drawText(Mage::helper('sales')->__('Credit Memo # ') . $creditmemo->getIncrementId(), 35, 780, 'UTF-8');
         /* Add table head */
         $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));
         $this->_drawHeader($page);
         $this->y -= 15;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         /* Add body */
         foreach ($creditmemo->getAllItems() as $item) {
             if ($item->getOrderItem()->getParentItem()) {
                 continue;
             }
             $shift = array();
             if ($this->y < 20) {
                 /* 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;
                 $this->_drawHeader($page);
                 $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
                 $this->y -= 20;
             }
             /* Draw item */
             $this->_drawItem($item, $page, $order);
         }
         /* Add totals */
         $this->insertTotals($page, $creditmemo);
     }
     $this->_afterGetPdf();
     return $pdf;
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:60,代码来源:Creditmemo.php


示例2: execute

 /**
  * Print label for one specific shipment
  *
  * @return ResponseInterface|void
  */
 public function execute()
 {
     try {
         $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
         $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
         $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
         $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
         $shipment = $this->shipmentLoader->load();
         $labelContent = $shipment->getShippingLabel();
         if ($labelContent) {
             $pdfContent = null;
             if (stripos($labelContent, '%PDF-') !== false) {
                 $pdfContent = $labelContent;
             } else {
                 $pdf = new \Zend_Pdf();
                 $page = $this->labelGenerator->createPdfPageFromImageString($labelContent);
                 if (!$page) {
                     $this->messageManager->addError(__('We don\'t recognize or support the file extension in this shipment: %1.', $shipment->getIncrementId()));
                 }
                 $pdf->pages[] = $page;
                 $pdfContent = $pdf->render();
             }
             return $this->_fileFactory->create('ShippingLabel(' . $shipment->getIncrementId() . ').pdf', $pdfContent, DirectoryList::VAR_DIR, 'application/pdf');
         }
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         $this->messageManager->addError(__('An error occurred while creating shipping label.'));
     }
     $this->_redirect('adminhtml/order_shipment/view', ['shipment_id' => $this->getRequest()->getParam('shipment_id')]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:37,代码来源:PrintLabel.php


示例3: 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:RainyBlueSky,项目名称:PHProjekt,代码行数:40,代码来源:Pdf.php


示例4: _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


示例5: createPdfTemplate

 /**
  *
  * @return Zend_Pdf
  *
  */
 protected function createPdfTemplate()
 {
     if ($this->getDi()->config->get('invoice_custom_template') && ($upload = $this->getDi()->uploadTable->load($this->getDi()->config->get('invoice_custom_template')))) {
         $pdf = Zend_Pdf::load($upload->getFullPath());
         $this->pointer = $this->getPaperHeight() - $this->getDi()->config->get('invoice_skip', 150);
     } else {
         $pdf = new Zend_Pdf();
         $pdf->pages[0] = $pdf->newPage($this->getDi()->config->get('invoice_format', Zend_Pdf_Page::SIZE_LETTER));
         $this->pointer = $this->drawDefaultTemplate($pdf);
     }
     return $pdf;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:17,代码来源:Invoice.php


示例6: 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


示例7: 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


示例8: 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


示例9: adjustPdf

 /**
  * test to combine Zend_Pdf content with tcpdf pdfs
  *
  * @param $observer
  */
 public function adjustPdf($observer)
 {
     $extractor = new Zend_Pdf_Resource_Extractor();
     $pdf = $observer->getEvent()->getPdf();
     $counter = false;
     foreach ($pdf->pages as $key => &$page) {
         if ($page instanceof Fooman_PdfCustomiser_Model_Abstract) {
             $counter = 1;
             $instance = $page;
             $firstKey = $key;
             unset($pdf->pages[$key]);
         } elseif ($counter == 1) {
             $objectArray = $page;
             $counter++;
             unset($pdf->pages[$key]);
         } elseif ($counter == 2) {
             $orderIds = $page;
             $tcpdf = Zend_Pdf::parse($instance->renderPdf($objectArray, $orderIds, null, true));
             foreach ($tcpdf->pages as $p) {
                 $pdf->pages[$firstKey] = $extractor->clonePage($p);
             }
             $counter = 0;
         }
     }
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:30,代码来源:Observer.php


示例10: render

 /**
  * Create Label
  *
  * @return string
  * @throws Zend_Pdf_Exception
  * @throws InvalidArgumentException
  */
 public function render()
 {
     $pdf = new Zend_Pdf();
     $pdfBuilder = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_PageBuilder();
     $template = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
     $pdfBuilder->setPage($template)->addProductName((string) $this->_info->ProductShortName)->addProductContentCode((string) $this->_info->ProductContentCode)->addSenderInfo($this->_info->Shipper)->addOriginInfo((string) $this->_info->OriginServiceArea->ServiceAreaCode)->addReceiveInfo($this->_info->Consignee)->addDestinationFacilityCode((string) $this->_info->Consignee->CountryCode, (string) $this->_info->DestinationServiceArea->ServiceAreaCode, (string) $this->_info->DestinationServiceArea->FacilityCode)->addServiceFeaturesCodes()->addDeliveryDateCode()->addShipmentInformation($this->_request->getOrderShipment())->addDateInfo($this->_info->ShipmentDate)->addWeightInfo((string) $this->_info->ChargeableWeight, (string) $this->_info->WeightUnit)->addWaybillBarcode((string) $this->_info->AirwayBillNumber, (string) $this->_info->Barcodes->AWBBarCode)->addRoutingBarcode((string) $this->_info->DHLRoutingCode, (string) $this->_info->DHLRoutingDataId, (string) $this->_info->Barcodes->DHLRoutingBarCode)->addBorder();
     $packages = array_values($this->_request->getPackages());
     $i = 0;
     foreach ($this->_info->Pieces->Piece as $piece) {
         $page = new Mage_Usa_Model_Shipping_Carrier_Dhl_Label_Pdf_Page($template);
         $pdfBuilder->setPage($page)->addPieceNumber((int) $piece->PieceNumber, (int) $this->_info->Piece)->addContentInfo($packages[$i])->addPieceIdBarcode((string) $piece->DataIdentifier, (string) $piece->LicensePlate, (string) $piece->LicensePlateBarCode);
         array_push($pdf->pages, $page);
         $i++;
     }
     return $pdf->render();
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:23,代码来源:Pdf.php


示例11: getPdf

 /**
  * keep compatible with the Zend_Pdf way of doing things
  * collect input for later processing with render()
  *
  * @param array $input    array of items to print
  * @param array $orderIds array of order ids
  *
  * @return Fooman_PdfCustomiser_Model_Abstract | Zend_Pdf
  */
 public function getPdf($input = array(), $orderIds = null)
 {
     if (self::COMPAT_MODE) {
         try {
             $newPdf = new Zend_Pdf();
             $extractor = new Zend_Pdf_Resource_Extractor();
             if (!empty($orderIds)) {
                 $origPdf = $this->renderPdf(null, $orderIds, null, true);
             } else {
                 $origPdf = $this->renderPdf($input, $orderIds, null, true);
             }
             if ($origPdf->getPdfAnyOutput()) {
                 $pdfString = $origPdf->Output('output.pdf', 'S');
                 $tcpdf = Zend_Pdf::parse($pdfString);
                 foreach ($tcpdf->pages as $p) {
                     $newPdf->pages[] = $extractor->clonePage($p);
                 }
             }
             return $newPdf;
         } catch (Exception $e) {
             Mage::logException($e);
         }
     } else {
         $this->pages[] = array('instance' => $this, 'objectArray' => $input, 'orderIds' => $orderIds);
         return $this;
     }
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:36,代码来源:Abstract.php


示例12: testRender

 public function testRender()
 {
     $pdf = \Zend_Pdf::load(__DIR__ . '/MSWord.pdf');
     $expected = \Zend_Pdf::load(__DIR__ . '/MSWordExpected.pdf');
     $gemsPdf = $this->loader->getPdf();
     // Start code to expose protected method
     $addTokenToDocument = function (\Zend_Pdf $pdf, $tokenId, $surveyId) {
         return $this->addTokenToDocument($pdf, $tokenId, $surveyId);
     };
     $testObject = $addTokenToDocument->bindTo($gemsPdf, $gemsPdf);
     // End code to expose protected method
     $testObject($pdf, "abcd-efgh", 1);
     // fix the date to prevent differences
     $pdf->properties['ModDate'] = 'D:' . str_replace(':', "'", date('YmdHisP', 1458048768)) . "'";
     // Uncomment to update the test pdf
     /*
      $stream = fopen(__DIR__ . '/MSWordExpected.pdf', 'w');
      $pdf->render(false, $stream);
      fclose($stream);
     */
     // This will trigger the warning in #812: Warning when printing a survey pdf that was created using Word
     // This warning will cause the test to fail
     $pdf->render();
     $this->assertEquals($expected->getMetadata(), $pdf->getMetadata());
     $this->assertEquals($expected->properties, $pdf->properties);
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:26,代码来源:PdfTest.php


示例13: __construct

 /**
  * Object constructor
  *
  * @param string  $data
  * @param boolean $storeContent
  */
 private function __construct($data, $storeContent)
 {
     try {
         $zendpdf = \Zend_Pdf::parse($data);
         // Store meta data properties
         if (isset($zendpdf->properties['Title'])) {
             $this->addField(\Zend_Search_Lucene_Field::UnStored('title', $zendpdf->properties['Title']));
         }
         if (isset($zendpdf->properties['Author'])) {
             $this->addField(\Zend_Search_Lucene_Field::UnStored('author', $zendpdf->properties['Author']));
         }
         if (isset($zendpdf->properties['Subject'])) {
             $this->addField(\Zend_Search_Lucene_Field::UnStored('subject', $zendpdf->properties['Subject']));
         }
         if (isset($zendpdf->properties['Keywords'])) {
             $this->addField(\Zend_Search_Lucene_Field::UnStored('keywords', $zendpdf->properties['Keywords']));
         }
         //TODO handle PDF 1.6 metadata Zend_Pdf::getMetadata()
         //do the content extraction
         $pdfParse = new \App_Search_Helper_PdfParser();
         $body = $pdfParse->pdf2txt($zendpdf->render());
         if ($body != '') {
             // Store contents
             if ($storeContent) {
                 $this->addField(\Zend_Search_Lucene_Field::Text('body', $body, 'UTF-8'));
             } else {
                 $this->addField(\Zend_Search_Lucene_Field::UnStored('body', $body, 'UTF-8'));
             }
         }
     } catch (\Exception $e) {
         Util::writeLog('search_lucene', $e->getMessage() . ' Trace:\\n' . $e->getTraceAsString(), Util::ERROR);
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:39,代码来源:Pdf.php


示例14: index

 /**
  * Extract data from a PDF document and add this to the Lucene index.
  *
  * @param string $pdfPath                       The path to the PDF document.
  * @param Zend_Search_Lucene_Proxy $luceneIndex The Lucene index object.
  * @return Zend_Search_Lucene_Proxy
  */
 public static function index($pdfPath, $luceneIndex)
 {
     // Load the PDF document.
     $pdf = Zend_Pdf::load($pdfPath);
     $key = md5($pdfPath);
     /**
      * Set up array to contain the document index data.
      * The Filename will be used to retrive the document if it is found in
      * the search resutls.
      * The Key will be used to uniquely identify the document so we can
      * delete it from the search index.
      */
     $indexValues = array('Filename' => $pdfPath, 'Key' => $key, 'Title' => '', 'Author' => '', 'Subject' => '', 'Keywords' => '', 'Creator' => '', 'Producer' => '', 'CreationDate' => '', 'ModDate' => '', 'Contents' => '');
     // Go through each meta data item and add to index array.
     foreach ($pdf->properties as $meta => $metaValue) {
         switch ($meta) {
             case 'Title':
                 $indexValues['Title'] = $pdf->properties['Title'];
                 break;
             case 'Subject':
                 $indexValues['Subject'] = $pdf->properties['Subject'];
                 break;
             case 'Author':
                 $indexValues['Author'] = $pdf->properties['Author'];
                 break;
             case 'Keywords':
                 $indexValues['Keywords'] = $pdf->properties['Keywords'];
                 break;
             case 'CreationDate':
                 $dateCreated = $pdf->properties['CreationDate'];
                 $distance = substr($dateCreated, 16, 2);
                 if (!is_long($distance)) {
                     $distance = null;
                 }
                 // Convert date from the PDF format of D:20090731160351+01'00'
                 $dateCreated = mktime(substr($dateCreated, 10, 2), substr($dateCreated, 12, 2), substr($dateCreated, 14, 2), substr($dateCreated, 6, 2), substr($dateCreated, 8, 2), substr($dateCreated, 2, 4), $distance);
                 //distance
                 $indexValues['CreationDate'] = date('Ymd', $dateCreated);
                 break;
             case 'Date':
                 $indexValues['Date'] = $pdf->properties['Date'];
                 break;
         }
     }
     /**
      * Parse the contents of the PDF document and pass the text to the
      * contents item in the $indexValues array.
      */
     $pdfParse = new App_Search_Helper_PdfParser();
     $indexValues['Contents'] = $pdfParse->pdf2txt($pdf->render());
     // Create the document using the values
     $doc = new App_Search_Lucene_Document($indexValues);
     if ($doc !== false) {
         // If the document creation was sucessful then add it to our index.
         $luceneIndex->addDocument($doc);
     }
     // Return the Lucene index object.
     return $luceneIndex;
 }
开发者ID:philipnorton42,项目名称:PDFSearch,代码行数:66,代码来源:Pdfs.php


示例15: __construct

 /**
  * Constructor.
  *
  * @param mixed $param1
  * @param mixed $param2
  * @param mixed $param3
  *
  * @throws Zend_Pdf_Exception
  *
  * @return void
  */
 public function __construct($param1, $param2 = NULL, $param3 = NULL)
 {
     parent::__construct($param1, $param2, $param3);
     if ($param1 instanceof FFR_Pdf_PdfGenerator && $param2 === null && $param3 === null) {
         // Clone additional properties
         $this->setBorder($param1->borderTop, $param1->borderRight, $param1->borderBottom, $param1->borderLeft);
     }
 }
开发者ID:rantoine,项目名称:AdvisorIllustrator,代码行数:19,代码来源:PdfGenerator.php


示例16: extract

 /** extract metadata */
 public function extract($revision)
 {
     /** @var ItemRevisionModel $itemRevisionModel */
     $itemRevisionModel = MidasLoader::loadModel('ItemRevision');
     $revision = $itemRevisionModel->load($revision['itemrevision_id']);
     if (!$revision) {
         return;
     }
     $bitstreams = $revision->getBitstreams();
     if (count($bitstreams) != 1) {
         return;
     }
     $bitstream = $bitstreams[0];
     $ext = strtolower(substr(strrchr($bitstream->getName(), '.'), 1));
     /** @var MetadataModel $metadataModel */
     $metadataModel = MidasLoader::loadModel('Metadata');
     if ($ext == 'pdf') {
         $pdf = Zend_Pdf::load($bitstream->getFullPath());
         foreach ($pdf->properties as $name => $property) {
             $name = strtolower($name);
             try {
                 $metadataDao = $metadataModel->getMetadata(MIDAS_METADATA_TEXT, 'misc', $name);
                 if (!$metadataDao) {
                     $metadataModel->addMetadata(MIDAS_METADATA_TEXT, 'misc', $name, '');
                 }
                 $metadataModel->addMetadataValue($revision, MIDAS_METADATA_TEXT, 'misc', $name, $property);
             } catch (Zend_Exception $exc) {
                 echo $exc->getMessage();
             }
         }
     } else {
         /** @var SettingModel $settingModel */
         $settingModel = MidasLoader::loadModel('Setting');
         $command = $settingModel->getValueByName(METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_KEY, $this->moduleName);
         exec(str_replace("'", '"', $command) . ' "' . $bitstream->getFullPath() . '"', $output);
         if (!isset($output[0]) || $output[0] != 'Metadata:') {
             return;
         }
         unset($output[0]);
         foreach ($output as $out) {
             $out = substr($out, 2);
             $pos = strpos($out, ': ');
             $name = strtolower(substr($out, 0, $pos));
             $value = substr($out, $pos + 2);
             try {
                 $metadataDao = $metadataModel->getMetadata(MIDAS_METADATA_TEXT, 'misc', $name);
                 if (!$metadataDao) {
                     $metadataModel->addMetadata(MIDAS_METADATA_TEXT, 'misc', $name, '');
                 }
                 $metadataModel->addMetadataValue($revision, MIDAS_METADATA_TEXT, 'misc', $name, $value);
             } catch (Zend_Exception $exc) {
                 echo $exc->getMessage();
             }
         }
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:57,代码来源:ExtractorComponent.php


示例17: pdfgenerationAction

 function pdfgenerationAction()
 {
     //$fetchMeetings=new Meetingreport_Model_Meetingreport();
     $pdf = new Zend_Pdf();
     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     // 		 $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4_LANDSCAPE);
     $pdf->pages[] = $page;
     // Image
     $app = $this->view->baseUrl();
     $word = explode('/', $app);
     $projname = '';
     for ($i = 0; $i < count($word); $i++) {
         if ($i > 0 && $i < count($word) - 1) {
             $projname .= '/' . $word[$i];
         }
     }
     $image_name = "/var/www" . $app . "/images/logo.jpg";
     $image = Zend_Pdf_Image::imageWithPath($image_name);
     //$page->drawImage($image, 25, 770, 570, 820);
     $page->drawImage($image, 30, 770, 130, 820);
     $page->setLineWidth(1)->drawLine(25, 25, 570, 25);
     //bottom horizontal
     $page->setLineWidth(1)->drawLine(25, 25, 25, 820);
     //left vertical
     $page->setLineWidth(1)->drawLine(570, 25, 570, 820);
     //right vertical
     $page->setLineWidth(1)->drawLine(570, 820, 25, 820);
     //top horizontal
     $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 8);
     $text = array("Bank", "Branch", "Thumb Impression Declaration", "I hereby declare that Smt/sri ______________________ has given the thumb impression in the presence of me and his mother tongue", " ___________________________", "Date", "Yours sincerely");
     $x0 = 60;
     $x10 = 450;
     $x11 = 285;
     $page->drawText($text[0], $x0, 725);
     $page->drawText($text[1], $x0, 700);
     $page->drawText($text[2], $x0, 675);
     $page->drawText($text[3], $x0, 650);
     $page->drawText($text[4], $x0, 625);
     $page->drawText($text[5], $x0, 575);
     $page->drawText($text[6], $x10, 575);
     $page->setLineWidth(1)->drawLine(50, 750, 550, 750);
     $page->setLineWidth(1)->drawLine(50, 750, 50, 465);
     $page->setLineWidth(1)->drawLine(50, 750, 50, 465);
     $page->setLineWidth(1)->drawLine(50, 465, 550, 465);
     $page->setLineWidth(1)->drawLine(550, 465, 550, 750);
     $page->setLineWidth(1)->drawLine(50, 690, 550, 690);
     $page->setLineWidth(1)->drawLine(50, 670, 550, 670);
     $y1 = 700;
     $totalAmount = "0";
     $totaldebit = "0";
     $pdfData = $pdf->render();
     $pdf->save('/var/www' . $projname . '/reports/thumbdeclaration' . date('Y-m-d') . '.pdf');
     $path = '/var/www' . $projname . '/reports/thumbdeclaration' . date('Y-m-d') . '.pdf';
     chmod($path, 0777);
 }
开发者ID:maniargaurav,项目名称:OurBank,代码行数:55,代码来源:IndexController.php


示例18: editmetaAction

 public function editmetaAction()
 {
     // Get the form and send to the view.
     $form = new Form_PdfMeta();
     $this->view->form = $form;
     // Get the file and send the location to the view.
     $pdfPath = urldecode($this->_request->getParam('file'));
     $file = substr($pdfPath, strrpos($pdfPath, SLASH) + 1);
     $this->view->file = $file;
     // Define what meta data we are looking at.
     $metaValues = array('Title' => '', 'Author' => '', 'Subject' => '', 'Keywords' => '');
     if ($this->_request->isPost()) {
         // Get the current form values.
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             // Form values are valid.
             // Save the contents of the form to the associated meta data fields in the PDF.
             $pdf = Zend_Pdf::load($pdfPath);
             foreach ($metaValues as $meta => $metaValue) {
                 if (isset($formData[$meta])) {
                     $pdf->properties[$meta] = $formData[$meta];
                 } else {
                     $pdf->properties[$meta] = '';
                 }
             }
             $pdf->save($pdfPath);
             // Add to/update index.
             $config = Zend_Registry::get('config');
             $appLucene = App_Search_Lucene::open($config->luceneIndex);
             $index = App_Search_Lucene_Index_Pdfs::index($pdfPath, $appLucene);
             // Redirect the user to the list action of this controller.
             return $this->_helper->redirector('list', 'pdf', '', array())->setCode(301);
         } else {
             // Form values are not valid send the current values to the form.
             $form->populate($formData);
         }
     } else {
         // Make sure the file exists before we start doing anything with it.
         if (file_exists($pdfPath)) {
             // Extract any current meta data values from the PDF document
             $pdf = Zend_Pdf::load($pdfPath);
             foreach ($metaValues as $meta => $metaValue) {
                 if (isset($pdf->properties[$meta])) {
                     $metaValues[$meta] = $pdf->properties[$meta];
                 } else {
                     $metaValues[$meta] = '';
                 }
             }
             // Populate the form with out metadata values.
             $form->populate($metaValues);
         } else {
             // File doesn't exist.
         }
     }
 }
开发者ID:philipnorton42,项目名称:PDFSearch,代码行数:55,代码来源:PdfController.php


示例19: isValid

 /**
  * Returns true if and only if $value meets the validation requirements
  *
  * If $value fails validation, then this method returns false, and
  * getMessages() will return an array of messages that explain why the
  * validation failed.
  *
  * @param  mixed $value
  * @return boolean
  * @throws \Zend_Valid_Exception If validation of $value is impossible
  */
 public function isValid($value, $context = array())
 {
     // Only fail when file really can't be loaded.
     try {
         \Zend_Pdf::load($value);
         return true;
     } catch (\Zend_Pdf_Exception $e) {
         $this->_error(self::ERROR_INVALID_VERSION, $e->getMessage());
         return false;
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:22,代码来源:Pdf.php


示例20: getPdf

 /**
  * Format pdf file
  *
  * @param null $shipment
  * @return Zend_Pdf
  */
 public function getPdf($shipment = null)
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('shipment');
     $pdf = new Zend_Pdf();
     $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     $pdf->pages[] = $page;
     if ($shipment->getStoreId()) {
         Mage::app()->getLocale()->emulate($shipment->getStoreId());
         Mage::app()->setCurrentStore($shipment->getStoreId());
     }
     $this->_setFontRegular($page);
     $this->_drawHeaderBlock($page);
     $this->y = 740;
     $this->_drawPackageBlock($page);
     $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
     $this->_afterGetPdf();
     if ($shipment->getStoreId()) {
         Mage::app()->getLocale()->revert();
     }
     return $pdf;
 }
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:28,代码来源:Packaging.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Pdf_Action类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Paginator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap