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

PHP Zend_Pdf_Element_Reference_Table类代码示例

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

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



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

示例1: _loadXRefTable

 /**
  * Load XReference table and referenced objects
  *
  * @param integer $offset
  * @throws Zend_Pdf_Exception
  * @return Zend_Pdf_Trailer_Keeper
  */
 private function _loadXRefTable($offset)
 {
     $this->_pushContext();
     $this->_current = $offset;
     $refTable = new Zend_Pdf_Element_Reference_Table();
     $context = new Zend_Pdf_Element_Reference_Context($this, $refTable);
     $this->_currentContext = $context;
     $nextLexeme = $this->_readLexeme();
     if ($nextLexeme == 'xref') {
         /**
          * Common cross-reference table
          */
         $this->_skipWhiteSpace();
         while (($nextLexeme = $this->_readLexeme()) != 'trailer') {
             if (!ctype_digit($nextLexeme)) {
                 throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross-reference table subheader values must contain only digits.', $this->_current - strlen($nextLexeme)));
             }
             $objNum = (int) $nextLexeme;
             $refCount = $this->_readLexeme();
             if (!ctype_digit($refCount)) {
                 throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross-reference table subheader values must contain only digits.', $this->_current - strlen($refCount)));
             }
             $this->_skipWhiteSpace();
             while ($refCount > 0) {
                 $objectOffset = substr($this->_pdfString, $this->_current, 10);
                 if (!ctype_digit($objectOffset)) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Offset must contain only digits.', $this->_current));
                 }
                 // Force $objectOffset to be treated as decimal instead of octal number
                 for ($numStart = 0; $numStart < strlen($objectOffset) - 1; $numStart++) {
                     if ($objectOffset[$numStart] != '0') {
                         break;
                     }
                 }
                 $objectOffset = substr($objectOffset, $numStart);
                 $this->_current += 10;
                 if (!self::isWhiteSpace(ord($this->_pdfString[$this->_current]))) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_current));
                 }
                 $this->_current++;
                 $genNumber = substr($this->_pdfString, $this->_current, 5);
                 if (!ctype_digit($objectOffset)) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Offset must contain only digits.', $this->_current));
                 }
                 // Force $objectOffset to be treated as decimal instead of octal number
                 for ($numStart = 0; $numStart < strlen($genNumber) - 1; $numStart++) {
                     if ($genNumber[$numStart] != '0') {
                         break;
                     }
                 }
                 $genNumber = substr($genNumber, $numStart);
                 $this->_current += 5;
                 if (!self::isWhiteSpace(ord($this->_pdfString[$this->_current]))) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_current));
                 }
                 $this->_current++;
                 $inUseKey = $this->_pdfString[$this->_current];
                 $this->_current++;
                 switch ($inUseKey) {
                     case 'f':
                         // free entry
                         unset($this->_refTable[$objNum . ' ' . $genNumber . ' R']);
                         $refTable->addReference($objNum . ' ' . $genNumber . ' R', $objectOffset, false);
                         break;
                     case 'n':
                         // in-use entry
                         $refTable->addReference($objNum . ' ' . $genNumber . ' R', $objectOffset, true);
                 }
                 if (!self::isWhiteSpace(ord($this->_pdfString[$this->_current]))) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_current));
                 }
                 $this->_current++;
                 if (!self::isWhiteSpace(ord($this->_pdfString[$this->_current]))) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_current));
                 }
                 $this->_current++;
                 $refCount--;
                 $objNum++;
             }
         }
         $trailerDictOffset = $this->_current;
         $trailerDict = $this->_readElementalObject();
         if (!$trailerDict instanceof Zend_Pdf_Element_Dictionary) {
             throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X.  Dictionary expected after \'trailer\' keyword.', $trailerDictOffset));
         }
         $trailerObj = new Zend_Pdf_Trailer_Keeper($trailerDict, $context);
         if ($trailerDict->Prev instanceof Zend_Pdf_Element_Numeric || $trailerDict->Prev instanceof Zend_Pdf_Element_Reference) {
             $trailerObj->setPrev($this->_loadXRefTable($trailerDict->Prev->value));
             $context->getRefTable()->setParent($trailerObj->getPrev()->getRefTable());
         }
         /**
          * We set '/Prev' dictionary property to the current cross-reference section offset.
          * It doesn't correspond to the actual data, but is true when trailer will be used
//.........这里部分代码省略.........
开发者ID:jorgenils,项目名称:zend-framework,代码行数:101,代码来源:Parser.php


示例2: _loadXRefTable

 private function _loadXRefTable($offset)
 {
     $this->_stringParser->offset = $offset;
     $refTable = new Zend_Pdf_Element_Reference_Table();
     $context = new Zend_Pdf_Element_Reference_Context($this->_stringParser, $refTable);
     $this->_stringParser->setContext($context);
     $nextLexeme = $this->_stringParser->readLexeme();
     if ($nextLexeme == 'xref') {
         $this->_stringParser->skipWhiteSpace();
         while (($nextLexeme = $this->_stringParser->readLexeme()) != 'trailer') {
             if (!ctype_digit($nextLexeme)) {
                 throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross-reference table subheader values must contain only digits.', $this->_stringParser->offset - strlen($nextLexeme)));
             }
             $objNum = (int) $nextLexeme;
             $refCount = $this->_stringParser->readLexeme();
             if (!ctype_digit($refCount)) {
                 throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross-reference table subheader values must contain only digits.', $this->_stringParser->offset - strlen($refCount)));
             }
             $this->_stringParser->skipWhiteSpace();
             while ($refCount > 0) {
                 $objectOffset = substr($this->_stringParser->data, $this->_stringParser->offset, 10);
                 if (!ctype_digit($objectOffset)) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Offset must contain only digits.', $this->_stringParser->offset));
                 }
                 for ($numStart = 0; $numStart < strlen($objectOffset) - 1; $numStart++) {
                     if ($objectOffset[$numStart] != '0') {
                         break;
                     }
                 }
                 $objectOffset = substr($objectOffset, $numStart);
                 $this->_stringParser->offset += 10;
                 if (strpos("\t\n\f\r ", $this->_stringParser->data[$this->_stringParser->offset]) === false) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_stringParser->offset));
                 }
                 $this->_stringParser->offset++;
                 $genNumber = substr($this->_stringParser->data, $this->_stringParser->offset, 5);
                 if (!ctype_digit($objectOffset)) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Offset must contain only digits.', $this->_stringParser->offset));
                 }
                 for ($numStart = 0; $numStart < strlen($genNumber) - 1; $numStart++) {
                     if ($genNumber[$numStart] != '0') {
                         break;
                     }
                 }
                 $genNumber = substr($genNumber, $numStart);
                 $this->_stringParser->offset += 5;
                 if (strpos("\t\n\f\r ", $this->_stringParser->data[$this->_stringParser->offset]) === false) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_stringParser->offset));
                 }
                 $this->_stringParser->offset++;
                 $inUseKey = $this->_stringParser->data[$this->_stringParser->offset];
                 $this->_stringParser->offset++;
                 switch ($inUseKey) {
                     case 'f':
                         unset($this->_refTable[$objNum . ' ' . $genNumber . ' R']);
                         $refTable->addReference($objNum . ' ' . $genNumber . ' R', $objectOffset, false);
                         break;
                     case 'n':
                         $refTable->addReference($objNum . ' ' . $genNumber . ' R', $objectOffset, true);
                 }
                 if (!Zend_Pdf_StringParser::isWhiteSpace(ord($this->_stringParser->data[$this->_stringParser->offset]))) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_stringParser->offset));
                 }
                 $this->_stringParser->offset++;
                 if (!Zend_Pdf_StringParser::isWhiteSpace(ord($this->_stringParser->data[$this->_stringParser->offset]))) {
                     throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_stringParser->offset));
                 }
                 $this->_stringParser->offset++;
                 $refCount--;
                 $objNum++;
             }
         }
         $trailerDictOffset = $this->_stringParser->offset;
         $trailerDict = $this->_stringParser->readElement();
         if (!$trailerDict instanceof Zend_Pdf_Element_Dictionary) {
             throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X.  Dictionary expected after \'trailer\' keyword.', $trailerDictOffset));
         }
     } else {
         $xrefStream = $this->_stringParser->getObject($offset, $context);
         if (!$xrefStream instanceof Zend_Pdf_Element_Object_Stream) {
             throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X.  Cross-reference stream expected.', $offset));
         }
         $trailerDict = $xrefStream->dictionary;
         if ($trailerDict->Type->value != 'XRef') {
             throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X.  Cross-reference stream object must have /Type property assigned to /XRef.', $offset));
         }
         if ($trailerDict->W === null || $trailerDict->W->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
             throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross reference stream dictionary doesn\'t have W entry or it\'s not an array.', $offset));
         }
         $entryField1Size = $trailerDict->W->items[0]->value;
         $entryField2Size = $trailerDict->W->items[1]->value;
         $entryField3Size = $trailerDict->W->items[2]->value;
         if ($entryField2Size == 0 || $entryField3Size == 0) {
             throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Wrong W dictionary entry. Only type field of stream entries has default value and could be zero length.', $offset));
         }
         $xrefStreamData = $xrefStream->value;
         if ($trailerDict->Index !== null) {
             if ($trailerDict->Index->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
                 throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross reference stream dictionary Index entry must be an array.', $offset));
             }
//.........这里部分代码省略.........
开发者ID:subashemphasize,项目名称:test_site,代码行数:101,代码来源:Pdf_Pack.php


示例3: getNewGeneration

 /**
  * Get next generation number for free object
  *
  * @param integer $objNum
  * @return unknown
  */
 public function getNewGeneration($objNum)
 {
     if (isset($this->_usedObjects[$objNum])) {
         throw new Zend_Pdf_Exception('Object is not free');
     }
     if (isset($this->_generations[$objNum])) {
         return $this->_generations[$objNum];
     }
     if (isset($this->_parent)) {
         return $this->_parent->getNewGeneration($objNum);
     }
     throw new Zend_Pdf_Exception('Object not found.');
 }
开发者ID:dalinhuang,项目名称:popo,代码行数:19,代码来源:Table.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Pdf_Element_String类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Pdf_Element_Reference类代码示例发布时间: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