本文整理汇总了PHP中Zend_Pdf_Element类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf_Element类的具体用法?PHP Zend_Pdf_Element怎么用?PHP Zend_Pdf_Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Pdf_Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Object constructor
*
* @param Zend_Pdf_Element $rootDictionary root of name dictionary
*/
public function __construct(Zend_Pdf_Element $rootDictionary)
{
if ($rootDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Name tree root must be a dictionary.');
}
$intermediateNodes = array();
$leafNodes = array();
if ($rootDictionary->Kids !== null) {
$intermediateNodes[] = $rootDictionary;
} else {
$leafNodes[] = $rootDictionary;
}
while (count($intermediateNodes) != 0) {
$newIntermediateNodes = array();
foreach ($intermediateNodes as $node) {
foreach ($node->Kids->items as $childNode) {
if ($childNode->Kids !== null) {
$newIntermediateNodes[] = $childNode;
} else {
$leafNodes[] = $childNode;
}
}
}
$intermediateNodes = $newIntermediateNodes;
}
foreach ($leafNodes as $leafNode) {
$destinationsCount = count($leafNode->Names->items) / 2;
for ($count = 0; $count < $destinationsCount; $count++) {
$this->_items[$leafNode->Names->items[$count * 2]->value] = $leafNode->Names->items[$count * 2 + 1];
}
}
}
示例2: __construct
/**
* Explicit destination object constructor
*
* @param Zend_Pdf_Element $destinationArray
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_Element $destinationArray)
{
if ($destinationArray->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Explicit destination resource Array must be a direct or an indirect array object.');
}
$this->_destinationArray = $destinationArray;
switch (count($this->_destinationArray->items)) {
case 0:
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Destination array must contain a page reference.');
break;
case 1:
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Destination array must contain a destination type name.');
break;
default:
// Do nothing
break;
}
switch ($this->_destinationArray->items[0]->getType()) {
case Zend_Pdf_Element::TYPE_NUMERIC:
$this->_isRemote = true;
break;
case Zend_Pdf_Element::TYPE_DICTIONARY:
$this->_isRemote = false;
break;
default:
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Destination target must be a page number or page dictionary object.');
break;
}
}
示例3: load
/**
* Parse resource and return it as an Action or Explicit Destination
*
* $param Zend_Pdf_Element $resource
* @return Zend_Pdf_Destination|
* @throws Zend_Pdf_Exception
*/
public static function load(Zend_Pdf_Element $resource)
{
require_once 'Zend/Pdf/Element.php';
if ($resource->getType() == Zend_Pdf_Element::TYPE_DICTIONARY) {
if (($resource->Type === null || $resource->Type->value == 'Action') && $resource->S !== null) {
// It's a well-formed action, load it
require_once 'Zend/Pdf/Action.php';
return Zend_Pdf_Action::load($resource);
} else {
if ($resource->D !== null) {
// It's a destination
$resource = $resource->D;
} else {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Wrong resource type.');
}
}
}
if ($resource->getType() == Zend_Pdf_Element::TYPE_ARRAY || $resource->getType() == Zend_Pdf_Element::TYPE_NAME || $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
// Resource is an array, just treat it as an explicit destination array
require_once 'Zend/Pdf/Destination.php';
return Zend_Pdf_Destination::load($resource);
} else {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Wrong resource type.');
}
}
示例4: __construct
/**
* Named destination object constructor
*
* @param Zend_Pdf_Element $resource
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_Element $resource)
{
if ($resource->getType() != Zend_Pdf_Element::TYPE_NAME && $resource->getType() != Zend_Pdf_Element::TYPE_STRING) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Named destination resource must be a PDF name or a PDF string.');
}
$this->_nameElement = $resource;
}
示例5: load
/**
* Load Destination object from a specified resource
*
* @internal
* @param Zend_Pdf_Element $resource
* @return Zend_Pdf_Destination
*/
public static function load(Zend_Pdf_Element $resource)
{
require_once 'Zend/Pdf/Element.php';
if ($resource->getType() == Zend_Pdf_Element::TYPE_NAME || $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
require_once 'Zend/Pdf/Destination/Named.php';
return new Zend_Pdf_Destination_Named($resource);
}
if ($resource->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('An explicit destination must be a direct or an indirect array object.');
}
if (count($resource->items) < 2) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('An explicit destination array must contain at least two elements.');
}
switch ($resource->items[1]->value) {
case 'XYZ':
require_once 'Zend/Pdf/Destination/Zoom.php';
return new Zend_Pdf_Destination_Zoom($resource);
break;
case 'Fit':
require_once 'Zend/Pdf/Destination/Fit.php';
return new Zend_Pdf_Destination_Fit($resource);
break;
case 'FitH':
require_once 'Zend/Pdf/Destination/FitHorizontally.php';
return new Zend_Pdf_Destination_FitHorizontally($resource);
break;
case 'FitV':
require_once 'Zend/Pdf/Destination/FitVertically.php';
return new Zend_Pdf_Destination_FitVertically($resource);
break;
case 'FitR':
require_once 'Zend/Pdf/Destination/FitRectangle.php';
return new Zend_Pdf_Destination_FitRectangle($resource);
break;
case 'FitB':
require_once 'Zend/Pdf/Destination/FitBoundingBox.php';
return new Zend_Pdf_Destination_FitBoundingBox($resource);
break;
case 'FitBH':
require_once 'Zend/Pdf/Destination/FitBoundingBoxHorizontally.php';
return new Zend_Pdf_Destination_FitBoundingBoxHorizontally($resource);
break;
case 'FitBV':
require_once 'Zend/Pdf/Destination/FitBoundingBoxVertically.php';
return new Zend_Pdf_Destination_FitBoundingBoxVertically($resource);
break;
default:
require_once 'Zend/Pdf/Destination/Unknown.php';
return new Zend_Pdf_Destination_Unknown($resource);
break;
}
}
示例6: __construct
/**
* Annotation object constructor
*
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_Element $annotationDictionary)
{
if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
}
if ($annotationDictionary->Subtype === null || $annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME || !in_array($annotationDictionary->Subtype->value, array(self::SUBTYPE_HIGHLIGHT, self::SUBTYPE_UNDERLINE, self::SUBTYPE_SQUIGGLY, self::SUBTYPE_STRIKEOUT))) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Subtype => Markup entry is omitted or has wrong value.');
}
parent::__construct($annotationDictionary);
}
示例7: __construct
/**
* Annotation object constructor
*
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_Element $annotationDictionary)
{
if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
//$1 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
}
if ($annotationDictionary->Subtype === null || $annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME || $annotationDictionary->Subtype->value != 'Link') {
//$1 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Subtype => Link entry is requires');
}
parent::__construct($annotationDictionary);
}
示例8: __construct
/**
* Annotation object constructor
*
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_Element $annotationDictionary)
{
if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
require_once PHP_LIBRARY_PATH . 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
}
if ($annotationDictionary->Subtype === null || $annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME || $annotationDictionary->Subtype->value != 'FileAttachment') {
require_once PHP_LIBRARY_PATH . 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Subtype => FileAttachment entry is requires');
}
parent::__construct($annotationDictionary);
}
示例9: load
/**
* Parse resource and return it as an Action or Explicit Destination
*
* $param Zend_Pdf_Element $resource
* @return Zend_Pdf_Destination|
* @throws Zend_Pdf_Exception
*/
public static function load(Zend_Pdf_Element $resource)
{
if ($resource->getType() == Zend_Pdf_Element::TYPE_DICTIONARY) {
// Load destination as appropriate action
return Zend_Pdf_Action::load($resource);
} else {
if ($resource->getType() == Zend_Pdf_Element::TYPE_ARRAY || $resource->getType() == Zend_Pdf_Element::TYPE_NAME || $resource->getType() == Zend_Pdf_Element::TYPE_STRING) {
// Resource is an array, just treat it as an explicit destination array
return Zend_Pdf_Destination::load($resource);
} else {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Wrong resource type.');
}
}
}
示例10: __construct
/**
* Object constructor.
*
* If resource is not a Zend_Pdf_Element object, then stream object with specified value is
* generated.
*
* @param Zend_Pdf_Element|string $resource
*/
public function __construct($resource)
{
if ($resource instanceof Zend_Pdf_Element_Object) {
$this->_objectFactory = $resource->getFactory();
$this->_resource = $resource;
return;
}
require_once 'Zend/Pdf/ElementFactory.php';
$this->_objectFactory = Zend_Pdf_ElementFactory::createFactory(1);
if ($resource instanceof Zend_Pdf_Element) {
$this->_resource = $this->_objectFactory->newObject($resource);
} else {
$this->_resource = $this->_objectFactory->newStreamObject($resource);
}
}
示例11: phpToPdf
/**
* Convert PHP value into PDF element.
*
* @param mixed $input
* @return Zend_Pdf_Element
*/
public static function phpToPdf($input)
{
if (is_numeric($input)) {
//require_once 'Zend/Pdf/Element/Numeric.php';
return new Zend_Pdf_Element_Numeric($input);
} else {
if (is_bool($input)) {
//require_once 'Zend/Pdf/Element/Boolean.php';
return new Zend_Pdf_Element_Boolean($input);
} else {
if (is_array($input)) {
$pdfElementsArray = array();
$isDictionary = false;
foreach ($input as $key => $value) {
if (is_string($key)) {
$isDictionary = true;
}
$pdfElementsArray[$key] = Zend_Pdf_Element::phpToPdf($value);
}
if ($isDictionary) {
//require_once 'Zend/Pdf/Element/Dictionary.php';
return new Zend_Pdf_Element_Dictionary($pdfElementsArray);
} else {
//require_once 'Zend/Pdf/Element/Array.php';
return new Zend_Pdf_Element_Array($pdfElementsArray);
}
} else {
//require_once 'Zend/Pdf/Element/String.php';
return new Zend_Pdf_Element_String((string) $input);
}
}
}
}
示例12: load
/**
* Load PDF action object using specified dictionary
*
* @internal
* @param Zend_Pdf_Element $dictionary (It's actually Dictionary or Dictionary Object or Reference to a Dictionary Object)
* @param SplObjectStorage $processedActions list of already processed action dictionaries, used to avoid cyclic references
* @return Zend_Pdf_Action
* @throws Zend_Pdf_Exception
*/
public static function load(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions = null)
{
if ($processedActions === null) {
$processedActions = new SplObjectStorage();
}
require_once 'Zend/Pdf/Element.php';
if ($dictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('$dictionary mast be a direct or an indirect dictionary object.');
}
if (isset($dictionary->Type) && $dictionary->Type->value != 'Action') {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Action dictionary Type entry must be set to \'Action\'.');
}
if ($dictionary->S === null) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Action dictionary must contain S entry');
}
switch ($dictionary->S->value) {
case 'GoTo':
require_once 'Zend/Pdf/Action/GoTo.php';
return new Zend_Pdf_Action_GoTo($dictionary, $processedActions);
brake;
case 'GoToR':
require_once 'Zend/Pdf/Action/GoToR.php';
return new Zend_Pdf_Action_GoToR($dictionary, $processedActions);
brake;
case 'GoToE':
require_once 'Zend/Pdf/Action/GoToE.php';
return new Zend_Pdf_Action_GoToE($dictionary, $processedActions);
brake;
case 'Launch':
require_once 'Zend/Pdf/Action/Launch.php';
return new Zend_Pdf_Action_Launch($dictionary, $processedActions);
brake;
case 'Thread':
require_once 'Zend/Pdf/Action/Thread.php';
return new Zend_Pdf_Action_Thread($dictionary, $processedActions);
brake;
case 'URI':
require_once 'Zend/Pdf/Action/URI.php';
return new Zend_Pdf_Action_URI($dictionary, $processedActions);
brake;
case 'Sound':
require_once 'Zend/Pdf/Action/Sound.php';
return new Zend_Pdf_Action_Sound($dictionary, $processedActions);
brake;
case 'Movie':
require_once 'Zend/Pdf/Action/Movie.php';
return new Zend_Pdf_Action_Movie($dictionary, $processedActions);
brake;
case 'Hide':
require_once 'Zend/Pdf/Action/Hide.php';
return new Zend_Pdf_Action_Hide($dictionary, $processedActions);
brake;
case 'Named':
require_once 'Zend/Pdf/Action/Named.php';
return new Zend_Pdf_Action_Named($dictionary, $processedActions);
brake;
case 'SubmitForm':
require_once 'Zend/Pdf/Action/SubmitForm.php';
return new Zend_Pdf_Action_SubmitForm($dictionary, $processedActions);
brake;
case 'ResetForm':
require_once 'Zend/Pdf/Action/ResetForm.php';
return new Zend_Pdf_Action_ResetForm($dictionary, $processedActions);
brake;
case 'ImportData':
require_once 'Zend/Pdf/Action/ImportData.php';
return new Zend_Pdf_Action_ImportData($dictionary, $processedActions);
brake;
case 'JavaScript':
require_once 'Zend/Pdf/Action/JavaScript.php';
return new Zend_Pdf_Action_JavaScript($dictionary, $processedActions);
brake;
case 'SetOCGState':
require_once 'Zend/Pdf/Action/SetOCGState.php';
return new Zend_Pdf_Action_SetOCGState($dictionary, $processedActions);
brake;
case 'Rendition':
require_once 'Zend/Pdf/Action/Rendition.php';
return new Zend_Pdf_Action_Rendition($dictionary, $processedActions);
brake;
case 'Trans':
require_once 'Zend/Pdf/Action/Trans.php';
return new Zend_Pdf_Action_Trans($dictionary, $processedActions);
brake;
case 'GoTo3DView':
require_once 'Zend/Pdf/Action/GoTo3DView.php';
return new Zend_Pdf_Action_GoTo3DView($dictionary, $processedActions);
brake;
//.........这里部分代码省略.........
示例13: __construct
/**
* Annotation object constructor
*
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_Element $annotationDictionary)
{
if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
}
$this->_annotationDictionary = $annotationDictionary;
if ($this->_annotationDictionary->Type !== null && $this->_annotationDictionary->Type->value != 'Annot') {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Wrong resource type. \'Annot\' expected.');
}
if ($this->_annotationDictionary->Rect === null) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('\'Rect\' dictionary entry is required.');
}
if (count($this->_annotationDictionary->Rect->items) != 4 || $this->_annotationDictionary->Rect->items[0]->getType() != Zend_Pdf_Element::TYPE_NUMERIC || $this->_annotationDictionary->Rect->items[1]->getType() != Zend_Pdf_Element::TYPE_NUMERIC || $this->_annotationDictionary->Rect->items[2]->getType() != Zend_Pdf_Element::TYPE_NUMERIC || $this->_annotationDictionary->Rect->items[3]->getType() != Zend_Pdf_Element::TYPE_NUMERIC) {
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('\'Rect\' dictionary entry must be an array of four numeric elements.');
}
}
示例14: setParentObject
/**
* Set top level parent indirect object.
*
* @param Zend_Pdf_Element_Object $parent
*/
public function setParentObject(Zend_Pdf_Element_Object $parent)
{
parent::setParentObject($parent);
foreach ($this->items as $item) {
$item->setParentObject($parent);
}
}
示例15: render
/**
* Render the completed PDF to a string.
* If $newSegmentOnly is true and it's not a new document,
* then only appended part of PDF is returned.
*
* @param boolean $newSegmentOnly
* @param resource $outputStream
* @return string
* @throws Zend_Pdf_Exception
*/
public function render($newSegmentOnly = false, $outputStream = null)
{
if ($this->_isNewDocument) {
// Drop full document first time even $newSegmentOnly is set to true
$newSegmentOnly = false;
$this->_isNewDocument = false;
}
// Save document properties if necessary
if ($this->properties != $this->_originalProperties) {
$docInfo = $this->_objFactory->newObject(new Zend_Pdf_Element_Dictionary());
foreach ($this->properties as $key => $value) {
switch ($key) {
case 'Trapped':
switch ($value) {
case true:
$docInfo->$key = new Zend_Pdf_Element_Name('True');
break;
case false:
$docInfo->$key = new Zend_Pdf_Element_Name('False');
break;
case null:
$docInfo->$key = new Zend_Pdf_Element_Name('Unknown');
break;
default:
require_once 'Zend/Pdf/Exception.php';
throw new Zend_Pdf_Exception('Wrong Trapped document property vale: \'' . $value . '\'. Only true, false and null values are allowed.');
break;
}
case 'CreationDate':
// break intentionally omitted
case 'ModDate':
$docInfo->$key = new Zend_Pdf_Element_String((string)$value);
break;
case 'Title':
// break intentionally omitted
case 'Author':
// break intentionally omitted
case 'Subject':
// break intentionally omitted
case 'Keywords':
// break intentionally omitted
case 'Creator':
// break intentionally omitted
case 'Producer':
if (extension_loaded('mbstring') === true) {
$detected = mb_detect_encoding($value);
if ($detected !== 'ASCII') {
$value = "\xfe\xff" . mb_convert_encoding($value, 'UTF-16', $detected);
}
}
$docInfo->$key = new Zend_Pdf_Element_String((string)$value);
break;
default:
// Set property using PDF type based on PHP type
$docInfo->$key = Zend_Pdf_Element::phpToPdf($value);
break;
}
}
$this->_trailer->Info = $docInfo;
}
$this->_dumpPages();
$this->_dumpNamedDestinations();
$this->_dumpOutlines();
// Check, that PDF file was modified
// File is always modified by _dumpPages() now, but future implementations may eliminate this.
if (!$this->_objFactory->isModified()) {
if ($newSegmentOnly) {
// Do nothing, return
return '';
}
if ($outputStream === null) {
return $this->_trailer->getPDFString();
} else {
$pdfData = $this->_trailer->getPDFString();
while ( strlen($pdfData) > 0 && ($byteCount = fwrite($outputStream, $pdfData)) != false ) {
$pdfData = substr($pdfData, $byteCount);
}
//.........这里部分代码省略.........