/** * Encode stream * * @throws Zend_Pdf_Exception */ private function _encodeStream() { /** * All applied stream filters must be processed to encode stream. * If we don't recognize any of applied filetrs an exception should be thrown here */ if (isset($this->_originalDictionary['F'])) { /** @todo Check, how external files can be processed. */ throw new Zend_Pdf_Exception('External filters are not supported now.'); } $filters = array_reverse($this->_originalDictionary['Filter'], true); foreach ($filters as $id => $filterName) { switch ($filterName) { case 'ASCIIHexDecode': $this->_value->value = Zend_Pdf_Filter_AsciiHex::encode($this->_value->value); break; case 'ASCII85Decode': $this->_value->value = Zend_Pdf_Filter_Ascii85::encode($this->_value->value); break; case 'FlateDecode': $this->_value->value = Zend_Pdf_Filter_Compression_Flate::encode($this->_value->value, $this->_originalDictionary['DecodeParms'][$id]); break; case 'LZWDecode': $this->_value->value = Zend_Pdf_Filter_Compression_Lzw::encode($this->_value->value, $this->_originalDictionary['DecodeParms'][$id]); break; default: throw new Zend_Pdf_Exception('Unknown stream filter: \'' . $filterName . '\'.'); } } $this->_streamDecoded = true; }
/** * Encode stream * * @throws Zend_Pdf_Exception */ private function _encodeStream() { /** * All applied stream filters must be processed to encode stream. * If we don't recognize any of applied filetrs an exception should be thrown here */ if (isset($this->_initialDictionaryData['F'])) { /** @todo Check, how external files can be processed. */ require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception('External filters are not supported now.'); } $filters = array_reverse($this->_initialDictionaryData['Filter'], true); foreach ($filters as $id => $filterName) { $valueRef =& $this->_value->value->getRef(); $this->_value->value->touch(); switch ($filterName) { case 'ASCIIHexDecode': require_once 'Zend/Pdf/Filter/AsciiHex.php'; $valueRef = Zend_Pdf_Filter_AsciiHex::encode($valueRef); break; case 'ASCII85Decode': require_once 'Zend/Pdf/Filter/Ascii85.php'; $valueRef = Zend_Pdf_Filter_Ascii85::encode($valueRef); break; case 'FlateDecode': require_once 'Zend/Pdf/Filter/Compression/Flate.php'; $valueRef = Zend_Pdf_Filter_Compression_Flate::encode($valueRef, $this->_initialDictionaryData['DecodeParms'][$id]); break; case 'LZWDecode': require_once 'Zend/Pdf/Filter/Compression/Lzw.php'; $valueRef = Zend_Pdf_Filter_Compression_Lzw::encode($valueRef, $this->_initialDictionaryData['DecodeParms'][$id]); break; case 'RunLengthDecode': require_once 'Zend/Pdf/Filter/RunLength.php'; $valueRef = Zend_Pdf_Filter_RunLength::encode($valueRef); break; default: require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception('Unknown stream filter: \'' . $filterName . '\'.'); } } $this->_streamDecoded = false; }
private function _encodeStream() { if (isset($this->_initialDictionaryData['F'])) { throw new Zend_Pdf_Exception('External filters are not supported now.'); } $filters = array_reverse($this->_initialDictionaryData['Filter'], true); foreach ($filters as $id => $filterName) { $valueRef =& $this->_value->value->getRef(); $this->_value->value->touch(); switch ($filterName) { case 'ASCIIHexDecode': $valueRef = Zend_Pdf_Filter_AsciiHex::encode($valueRef); break; case 'ASCII85Decode': $valueRef = Zend_Pdf_Filter_Ascii85::encode($valueRef); break; case 'FlateDecode': $valueRef = Zend_Pdf_Filter_Compression_Flate::encode($valueRef, $this->_initialDictionaryData['DecodeParms'][$id]); break; case 'LZWDecode': $valueRef = Zend_Pdf_Filter_Compression_Lzw::encode($valueRef, $this->_initialDictionaryData['DecodeParms'][$id]); break; case 'RunLengthDecode': $valueRef = Zend_Pdf_Filter_RunLength::encode($valueRef); break; default: throw new Zend_Pdf_Exception('Unknown stream filter: \'' . $filterName . '\'.'); } } $this->_streamDecoded = false; }