24 #require_once 'Zend/Pdf/Element/Stream.php'; 25 #require_once 'Zend/Pdf/Element/Dictionary.php'; 26 #require_once 'Zend/Pdf/Element/Numeric.php'; 30 #require_once 'Zend/Pdf/Element/Object.php'; 56 private $_streamDecoded;
66 private $_initialDictionaryData =
null;
82 if ($dictionary ===
null) {
85 $this->_streamDecoded =
true;
87 $this->_dictionary = $dictionary;
88 $this->_streamDecoded =
false;
99 private function _extractDictionaryData()
101 $dictionaryArray = array();
103 $dictionaryArray[
'Filter'] = array();
104 $dictionaryArray[
'DecodeParms'] = array();
105 if ($this->_dictionary->Filter ===
null) {
108 foreach ($this->_dictionary->Filter->items as
$id => $filter) {
109 $dictionaryArray[
'Filter'][
$id] = $filter->value;
110 $dictionaryArray[
'DecodeParms'][
$id] = array();
112 if ($this->_dictionary->DecodeParms !==
null ) {
113 if ($this->_dictionary->DecodeParms->items[
$id] !==
null &&
114 $this->_dictionary->DecodeParms->items[
$id]->value !==
null ) {
115 foreach ($this->_dictionary->DecodeParms->items[
$id]->getKeys() as $paramKey) {
116 $dictionaryArray[
'DecodeParms'][
$id][$paramKey] =
117 $this->_dictionary->DecodeParms->items[
$id]->$paramKey->value;
123 $dictionaryArray[
'Filter'][0] = $this->_dictionary->Filter->value;
124 $dictionaryArray[
'DecodeParms'][0] = array();
125 if ($this->_dictionary->DecodeParms !==
null ) {
126 foreach ($this->_dictionary->DecodeParms->getKeys() as $paramKey) {
127 $dictionaryArray[
'DecodeParms'][0][$paramKey] =
128 $this->_dictionary->DecodeParms->$paramKey->value;
133 if ($this->_dictionary->F !==
null) {
134 $dictionaryArray[
'F'] = $this->_dictionary->F->value;
137 $dictionaryArray[
'FFilter'] = array();
138 $dictionaryArray[
'FDecodeParms'] = array();
139 if ($this->_dictionary->FFilter ===
null) {
142 foreach ($this->_dictionary->FFilter->items as
$id => $filter) {
143 $dictionaryArray[
'FFilter'][
$id] = $filter->value;
144 $dictionaryArray[
'FDecodeParms'][
$id] = array();
146 if ($this->_dictionary->FDecodeParms !==
null ) {
147 if ($this->_dictionary->FDecodeParms->items[
$id] !==
null &&
148 $this->_dictionary->FDecodeParms->items[
$id]->value !==
null) {
149 foreach ($this->_dictionary->FDecodeParms->items[
$id]->getKeys() as $paramKey) {
150 $dictionaryArray[
'FDecodeParms'][
$id][$paramKey] =
151 $this->_dictionary->FDecodeParms->items[
$id]->items[$paramKey]->value;
157 $dictionaryArray[
'FFilter'][0] = $this->_dictionary->FFilter->value;
158 $dictionaryArray[
'FDecodeParms'][0] = array();
159 if ($this->_dictionary->FDecodeParms !==
null ) {
160 foreach ($this->_dictionary->FDecodeParms->getKeys() as $paramKey) {
161 $dictionaryArray[
'FDecodeParms'][0][$paramKey] =
162 $this->_dictionary->FDecodeParms->items[$paramKey]->value;
167 return $dictionaryArray;
175 private function _decodeStream()
177 if ($this->_initialDictionaryData ===
null) {
178 $this->_initialDictionaryData = $this->_extractDictionaryData();
185 if (isset($this->_initialDictionaryData[
'F'])) {
187 #require_once 'Zend/Pdf/Exception.php'; 191 foreach ($this->_initialDictionaryData[
'Filter'] as
$id => $filterName ) {
192 $valueRef = &$this->_value->value->getRef();
193 $this->_value->value->touch();
194 switch ($filterName) {
195 case 'ASCIIHexDecode':
196 #require_once 'Zend/Pdf/Filter/AsciiHex.php'; 200 case 'ASCII85Decode':
201 #require_once 'Zend/Pdf/Filter/Ascii85.php'; 206 #require_once 'Zend/Pdf/Filter/Compression/Flate.php'; 208 $this->_initialDictionaryData[
'DecodeParms'][
$id]);
212 #require_once 'Zend/Pdf/Filter/Compression/Lzw.php'; 214 $this->_initialDictionaryData[
'DecodeParms'][
$id]);
217 case 'RunLengthDecode':
218 #require_once 'Zend/Pdf/Filter/RunLength.php'; 223 #require_once 'Zend/Pdf/Exception.php'; 228 $this->_streamDecoded = true; 236 private function _encodeStream() 242 if (isset($this->_initialDictionaryData['F
'])) { 244 #require_once 'Zend/Pdf/Exception.php
'; 245 throw new Zend_Pdf_Exception('External filters are not supported now.
'); 248 $filters = array_reverse($this->_initialDictionaryData['Filter
'], true); 250 foreach ($filters as $id => $filterName ) { 251 $valueRef = &$this->_value->value->getRef(); 252 $this->_value->value->touch(); 253 switch ($filterName) { 254 case 'ASCIIHexDecode
': 255 #require_once 'Zend/Pdf/Filter/AsciiHex.php
'; 256 $valueRef = Zend_Pdf_Filter_AsciiHex::encode($valueRef); 259 case 'ASCII85Decode
': 260 #require_once 'Zend/Pdf/Filter/Ascii85.php
'; 261 $valueRef = Zend_Pdf_Filter_Ascii85::encode($valueRef); 265 #require_once 'Zend/Pdf/Filter/Compression/Flate.php
'; 266 $valueRef = Zend_Pdf_Filter_Compression_Flate::encode($valueRef, 267 $this->_initialDictionaryData['DecodeParms
'][$id]); 271 #require_once 'Zend/Pdf/Filter/Compression/Lzw.php
'; 272 $valueRef = Zend_Pdf_Filter_Compression_Lzw::encode($valueRef, 273 $this->_initialDictionaryData['DecodeParms
'][$id]); 276 case 'RunLengthDecode
': 277 #require_once 'Zend/Pdf/Filter/RunLength.php
'; 278 $valueRef = Zend_Pdf_Filter_RunLength::encode($valueRef); 282 #require_once 'Zend/Pdf/Exception.php
'; 283 throw new Zend_Pdf_Exception('Unknown stream filter: \
'' . $filterName .
'\'.
'); 287 $this->_streamDecoded = false; 297 public function __get($property) 299 if ($property == 'dictionary
') { 303 if (( !$this->_streamDecoded ) && ($this->_initialDictionaryData === null)) { 304 $this->_initialDictionaryData = $this->_extractDictionaryData(); 307 return $this->_dictionary; 310 if ($property == 'value') { 311 if (!$this->_streamDecoded) { 312 $this->_decodeStream(); 315 return $this->_value->value->getRef(); 318 #require_once 'Zend/Pdf/Exception.php
'; 319 throw new Zend_Pdf_Exception('Unknown stream
object property requested.
'); 329 public function __set($property, $value) 331 if ($property == 'value
') { 332 $valueRef = &$this->_value->value->getRef(); 334 $this->_value->value->touch(); 336 $this->_streamDecoded = true; 341 #require_once 'Zend/Pdf/Exception.php
'; 342 throw new Zend_Pdf_Exception('Unknown stream
object property: \
'' . $property .
'\'.
'); 349 public function skipFilters() 351 $this->_streamDecoded = false; 362 public function __call($method, $args) 364 if (!$this->_streamDecoded) { 365 $this->_decodeStream(); 368 switch (count($args)) { 370 return $this->_value->$method(); 372 return $this->_value->$method($args[0]); 374 #require_once 'Zend/Pdf/Exception.php
'; 375 throw new Zend_Pdf_Exception('Unsupported number of arguments
'); 387 public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode) 389 $id = spl_object_hash($this); 390 if (isset($processed[$id])) { 391 // Do nothing if object is already processed 393 return $processed[$id]; 396 $streamValue = $this->_value; 397 $streamDictionary = $this->_dictionary->makeClone($factory, $processed, $mode); 399 // Make new empty instance of stream object and register it in $processed container 400 $processed[$id] = $clonedObject = $factory->newStreamObject(''); 402 // Copy current object data and state 403 $clonedObject->_dictionary = $this->_dictionary->makeClone($factory, $processed, $mode); 404 $clonedObject->_value = $this->_value->makeClone($factory, $processed, $mode); 405 $clonedObject->_initialDictionaryData = $this->_initialDictionaryData; 406 $clonedObject->_streamDecoded = $this->_streamDecoded; 408 return $clonedObject; 419 public function dump(Zend_Pdf_ElementFactory $factory) 421 $shift = $factory->getEnumerationShift($this->_factory); 423 if ($this->_streamDecoded) { 424 $this->_initialDictionaryData = $this->_extractDictionaryData(); 425 $this->_encodeStream(); 426 } else if ($this->_initialDictionaryData != null) { 427 $newDictionary = $this->_extractDictionaryData(); 429 if ($this->_initialDictionaryData !== $newDictionary) { 430 $this->_decodeStream(); 431 $this->_initialDictionaryData = $newDictionary; 432 $this->_encodeStream(); 436 // Update stream length 437 $this->dictionary->Length->value = $this->_value->length(); 439 return $this->_objNum + $shift . " " . $this->_genNum . " obj \n" 440 . $this->dictionary->toString($factory) . "\n" 441 . $this->_value->toString($factory) . "\n" 448 public function cleanUp() 450 $this->_dictionary = null; 451 $this->_value = null;
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
static decode($data, $params=null)
static decode($data, $params=null)
static decode($data, $params=null)
static decode($data, $params=null)
static decode($data, $params=null)
__construct($val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory, $dictionary=null)