本文整理汇总了PHP中Zend_Pdf_ElementFactory_Interface::resolve方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_ElementFactory_Interface::resolve方法的具体用法?PHP Zend_Pdf_ElementFactory_Interface::resolve怎么用?PHP Zend_Pdf_ElementFactory_Interface::resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Pdf_ElementFactory_Interface
的用法示例。
在下文中一共展示了Zend_Pdf_ElementFactory_Interface::resolve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObject
/**
* Read inderect object from a PDF stream
*
* @param integer $offset
* @param Zend_Pdf_Element_Reference_Context $context
* @return Zend_Pdf_Element_Object
*/
public function getObject($offset, Zend_Pdf_Element_Reference_Context $context)
{
if ($offset === null) {
return new Zend_Pdf_Element_Null();
}
// Save current offset to make getObject() reentrant
$offsetSave = $this->offset;
$this->offset = $offset;
$this->_context = $context;
$this->_elements = array();
$objNum = $this->readLexeme();
if (!ctype_digit($objNum)) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Object number expected.', $this->offset - strlen($objNum)));
}
$genNum = $this->readLexeme();
if (!ctype_digit($genNum)) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Object generation number expected.', $this->offset - strlen($genNum)));
}
$objKeyword = $this->readLexeme();
if ($objKeyword != 'obj') {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'obj\' keyword expected.', $this->offset - strlen($objKeyword)));
}
$objValue = $this->readElement();
$nextLexeme = $this->readLexeme();
if ($nextLexeme == 'endobj') {
/**
* Object is not generated by factory (thus it's not marked as modified object).
* But factory is assigned to the obect.
*/
$obj = new Zend_Pdf_Element_Object($objValue, (int) $objNum, (int) $genNum, $this->_objFactory->resolve());
foreach ($this->_elements as $element) {
$element->setParentObject($obj);
}
// Restore offset value
$this->offset = $offsetSave;
return $obj;
}
/**
* It's a stream object
*/
if ($nextLexeme != 'stream') {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'endobj\' or \'stream\' keywords expected.', $this->offset - strlen($nextLexeme)));
}
if (!$objValue instanceof Zend_Pdf_Element_Dictionary) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Stream extent must be preceded by stream dictionary.', $this->offset - strlen($nextLexeme)));
}
/**
* References are automatically dereferenced at this moment.
*/
$streamLength = $objValue->Length->value;
/**
* 'stream' keyword must be followed by either cr-lf sequence or lf character only.
* This restriction gives the possibility to recognize all cases exactly
*/
if ($this->data[$this->offset] == "\r" && $this->data[$this->offset + 1] == "\n") {
$this->offset += 2;
} else {
if ($this->data[$this->offset] == "\n") {
$this->offset++;
} else {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'stream\' must be followed by either cr-lf sequence or lf character only.', $this->offset - strlen($nextLexeme)));
}
}
$dataOffset = $this->offset;
$this->offset += $streamLength;
$nextLexeme = $this->readLexeme();
if ($nextLexeme != 'endstream') {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'endstream\' keyword expected.', $this->offset - strlen($nextLexeme)));
}
$nextLexeme = $this->readLexeme();
if ($nextLexeme != 'endobj') {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'endobj\' keyword expected.', $this->offset - strlen($nextLexeme)));
}
$obj = new Zend_Pdf_Element_Object_Stream(substr($this->data, $dataOffset, $streamLength), (int) $objNum, (int) $genNum, $this->_objFactory->resolve(), $objValue);
foreach ($this->_elements as $element) {
$element->setParentObject($obj);
}
// Restore offset value
$this->offset = $offsetSave;
return $obj;
}
示例2: resolve
/**
* Get source factory object
*
* @return Zend_Pdf_ElementFactory
*/
public function resolve()
{
return $this->_factory->resolve();
}