コード例 #1
0
ファイル: Ascii85Test.php プロジェクト: bradley-holt/zf2
 public function testStringNotDivisibleBy4Encode()
 {
     $decodedContents = 'Lorem ipsum dolor sit amet, consectetur cras amet.';
     $encodedContents = StreamFilter\ASCII85::encode($decodedContents);
     $testString = "9Q+r_D'3P3F*2=BA8c:&EZfF;F<G\"/ATTIG@rH7+ARfgn" . "FEMUH@rc\"!+CT+uF=m~>";
     $this->assertEquals($encodedContents, $testString);
 }
コード例 #2
0
ファイル: StreamObject.php プロジェクト: stunti/zf2
 /**
  * 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 PDF\Exception('External filters are not supported now.');
     }
     $filters = array_reverse($this->_originalDictionary['Filter'], true);
     foreach ($filters as $id => $filterName) {
         $valueRef =& $this->_value->value->getRef();
         $this->_value->value->touch();
         switch ($filterName) {
             case 'ASCIIHexDecode':
                 $valueRef = StreamFilter\ASCIIHex::encode($valueRef);
                 break;
             case 'ASCII85Decode':
                 $valueRef = StreamFilter\ASCII85::encode($valueRef);
                 break;
             case 'FlateDecode':
                 $valueRef = CompressionFilter\Flate::encode($valueRef, $this->_originalDictionary['DecodeParms'][$id]);
                 break;
             case 'LZWDecode':
                 $valueRef = CompressionFilter\LZW::encode($valueRef, $this->_originalDictionary['DecodeParms'][$id]);
                 break;
             case 'RunLengthDecode':
                 $valueRef = StreamFilter\RunLength::encode($valueRef);
                 break;
             default:
                 throw new PDF\Exception('Unknown stream filter: \'' . $filterName . '\'.');
         }
     }
     $this->_streamDecoded = false;
 }