File indexing completed on 2025-01-19 05:21:21
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Pdf 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 0023 /** Internally used classes */ 0024 // require_once 'Zend/Pdf.php'; 0025 0026 0027 /** Zend_Pdf_Element */ 0028 // require_once 'Zend/Pdf/Element.php'; 0029 0030 /** 0031 * PDF file 'stream' element implementation 0032 * 0033 * @category Zend 0034 * @package Zend_Pdf 0035 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0036 * @license http://framework.zend.com/license/new-bsd New BSD License 0037 */ 0038 class Zend_Pdf_Element_Stream extends Zend_Pdf_Element 0039 { 0040 /** 0041 * Object value 0042 * 0043 * @var Zend_Memory_Container 0044 */ 0045 public $value; 0046 0047 0048 /** 0049 * Object constructor 0050 * 0051 * @param string $val 0052 */ 0053 public function __construct($val) 0054 { 0055 $this->value = Zend_Pdf::getMemoryManager()->create($val); 0056 } 0057 0058 0059 /** 0060 * Return type of the element. 0061 * 0062 * @return integer 0063 */ 0064 public function getType() 0065 { 0066 return Zend_Pdf_Element::TYPE_STREAM; 0067 } 0068 0069 0070 /** 0071 * Stream length. 0072 * (Method is used to avoid string copying, which may occurs in some cases) 0073 * 0074 * @return integer 0075 */ 0076 public function length() 0077 { 0078 return strlen($this->value->getRef()); 0079 } 0080 0081 0082 /** 0083 * Clear stream 0084 * 0085 */ 0086 public function clear() 0087 { 0088 $ref = &$this->value->getRef(); 0089 $ref = ''; 0090 $this->value->touch(); 0091 } 0092 0093 0094 /** 0095 * Append value to a stream 0096 * 0097 * @param mixed $val 0098 */ 0099 public function append($val) 0100 { 0101 $ref = &$this->value->getRef(); 0102 $ref .= (string)$val; 0103 $this->value->touch(); 0104 } 0105 0106 0107 /** 0108 * Detach PDF object from the factory (if applicable), clone it and attach to new factory. 0109 * 0110 * @param Zend_Pdf_ElementFactory $factory The factory to attach 0111 * @param array &$processed List of already processed indirect objects, used to avoid objects duplication 0112 * @param integer $mode Cloning mode (defines filter for objects cloning) 0113 * @returns Zend_Pdf_Element 0114 */ 0115 public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode) 0116 { 0117 return new self($this->value->getRef()); 0118 } 0119 0120 /** 0121 * Return object as string 0122 * 0123 * @param Zend_Pdf_Factory $factory 0124 * @return string 0125 */ 0126 public function toString($factory = null) 0127 { 0128 return "stream\n" . $this->value->getRef() . "\nendstream"; 0129 } 0130 }