本文整理汇总了PHP中Zend_Pdf类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf类的具体用法?PHP Zend_Pdf怎么用?PHP Zend_Pdf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Pdf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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')]);
}
示例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();
}
示例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');
}
示例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;
}
示例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();
}
示例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');
}
示例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);
}
示例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;
}
}
}
示例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();
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}