source-class-Com.Tecnick.Pdf.Filter.Filter

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
 1: <?php
 2: /**
 3:  * Filter.php
 4:  *
 5:  * @since       2011-05-23
 6:  * @category    Library
 7:  * @package     PdfFilter
 8:  * @author      Nicola Asuni <info@tecnick.com>
 9:  * @copyright   2011-2015 Nicola Asuni - Tecnick.com LTD
10:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
11:  * @link        https://github.com/tecnickcom/tc-lib-pdf-filter
12:  *
13:  * This file is part of tc-lib-pdf-filter software library.
14:  */
15: 
16: namespace Com\Tecnick\Pdf\Filter;
17: 
18: use \Com\Tecnick\Pdf\Filter\Exception as PPException;
19: 
20: /**
21:  * Com\Tecnick\Pdf\Filter\Filter
22:  *
23:  * PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters)
24:  *
25:  * @since       2011-05-23
26:  * @category    Library
27:  * @package     PdfFilter
28:  * @author      Nicola Asuni <info@tecnick.com>
29:  * @copyright   2011-2015 Nicola Asuni - Tecnick.com LTD
30:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
31:  * @link        https://github.com/tecnickcom/tc-lib-pdf-filter
32:  */
33: class Filter
34: {
35:     /**
36:      * Define a list of available filter decoders.
37:      *
38:      * @var array
39:      */
40:     private static $filtermap = array(
41:         'ASCIIHexDecode'   => 'AsciiHex',
42:         'ASCII85Decode'    => 'AsciiEightFive',
43:         'LZWDecode'        => 'Lzw',
44:         'FlateDecode'      => 'Flate',
45:         'RunLengthDecode'  => 'RunLength',
46:         'CCITTFaxDecode'   => 'CcittFax',
47:         'JBIG2Decode'      => 'JbigTwo',
48:         'DCTDecode'        => 'Dct',
49:         'JPXDecode'        => 'Jpx',
50:         'Crypt'            => 'Crypt',
51:     );
52: 
53:     /**
54:      * Decode data using the specified filter type.
55:      *
56:      * @param string $filter Filter name.
57:      * @param string $data   Data to decode.
58:      *
59:      * @return string  Decoded data string.
60:      */
61:     public function decode($filter, $data)
62:     {
63:         if (empty($filter)) {
64:             return $data;
65:         }
66:         if (!isset(self::$filtermap[$filter])) {
67:             throw new PPException('unknown filter: '.$filter);
68:         }
69:         $class = '\\Com\\Tecnick\\Pdf\\Filter\\Type\\'.self::$filtermap[$filter];
70:         $obj = new $class;
71:         return $obj->decode($data);
72:     }
73: 
74:     /**
75:      * Decode the input data using multiple filters
76:      *
77:      * @param array  $filters Array of decoding filters to apply in order
78:      * @param string $data    Data to decode.
79:      *
80:      * @return string Decoded data
81:      */
82:     public function decodeAll($filters, $data)
83:     {
84:         foreach ($filters as $filter) {
85:             $data = $this->decode($filter, $data);
86:         }
87:         return $data;
88:     }
89: }
90: 
 

© 2004-2017 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy