File indexing completed on 2024-06-23 05:55:33
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 /** Zend_Pdf_Filter_Compression */ 0024 // require_once 'Zend/Pdf/Filter/Compression.php'; 0025 0026 /** 0027 * Flate stream filter 0028 * 0029 * @package Zend_Pdf 0030 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0031 * @license http://framework.zend.com/license/new-bsd New BSD License 0032 */ 0033 class Zend_Pdf_Filter_Compression_Flate extends Zend_Pdf_Filter_Compression 0034 { 0035 /** 0036 * Encode data 0037 * 0038 * @param string $data 0039 * @param array $params 0040 * @return string 0041 * @throws Zend_Pdf_Exception 0042 */ 0043 public static function encode($data, $params = null) 0044 { 0045 if ($params != null) { 0046 $data = self::_applyEncodeParams($data, $params); 0047 } 0048 0049 if (extension_loaded('zlib')) { 0050 $trackErrors = ini_get( "track_errors"); 0051 ini_set('track_errors', '1'); 0052 0053 if (($output = @gzcompress($data)) === false) { 0054 ini_set('track_errors', $trackErrors); 0055 // require_once 'Zend/Pdf/Exception.php'; 0056 throw new Zend_Pdf_Exception($php_errormsg); 0057 } 0058 0059 ini_set('track_errors', $trackErrors); 0060 } else { 0061 // require_once 'Zend/Pdf/Exception.php'; 0062 throw new Zend_Pdf_Exception('Not implemented yet. You have to use zlib extension.'); 0063 } 0064 0065 return $output; 0066 } 0067 0068 /** 0069 * Decode data 0070 * 0071 * @param string $data 0072 * @param array $params 0073 * @return string 0074 * @throws Zend_Pdf_Exception 0075 */ 0076 public static function decode($data, $params = null) 0077 { 0078 global $php_errormsg; 0079 0080 if (extension_loaded('zlib')) { 0081 $trackErrors = ini_get( "track_errors"); 0082 ini_set('track_errors', '1'); 0083 0084 if (($output = @gzuncompress($data)) === false) { 0085 ini_set('track_errors', $trackErrors); 0086 // require_once 'Zend/Pdf/Exception.php'; 0087 throw new Zend_Pdf_Exception($php_errormsg); 0088 } 0089 0090 ini_set('track_errors', $trackErrors); 0091 } else { 0092 // require_once 'Zend/Pdf/Exception.php'; 0093 throw new Zend_Pdf_Exception('Not implemented yet'); 0094 } 0095 0096 if ($params !== null) { 0097 return self::_applyDecodeParams($output, $params); 0098 } else { 0099 return $output; 0100 } 0101 } 0102 }