This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).
More...
|
static | getAvailableFilters () |
| Get a list of available decoding filters. More...
|
|
static | decodeFilter ($filter, $data) |
| Decode data using the specified filter type. More...
|
|
static | decodeFilterStandard ($data) |
| Standard Default decoding filter (leaves data unchanged). More...
|
|
static | decodeFilterASCIIHexDecode ($data) |
| ASCIIHexDecode Decodes data encoded in an ASCII hexadecimal representation, reproducing the original binary data. More...
|
|
static | decodeFilterASCII85Decode ($data) |
| ASCII85Decode Decodes data encoded in an ASCII base-85 representation, reproducing the original binary data. More...
|
|
static | decodeFilterLZWDecode ($data) |
| LZWDecode Decompresses data encoded using the LZW (Lempel-Ziv-Welch) adaptive compression method, reproducing the original text or binary data. More...
|
|
static | decodeFilterFlateDecode ($data) |
| FlateDecode Decompresses data encoded using the zlib/deflate compression method, reproducing the original text or binary data. More...
|
|
static | decodeFilterRunLengthDecode ($data) |
| RunLengthDecode Decompresses data encoded using a byte-oriented run-length encoding algorithm. More...
|
|
static | decodeFilterCCITTFaxDecode ($data) |
| CCITTFaxDecode (NOT IMPLEMETED - RETURN AN EXCEPTION) Decompresses data encoded using the CCITT facsimile standard, reproducing the original data (typically monochrome image data at 1 bit per pixel). More...
|
|
static | decodeFilterJBIG2Decode ($data) |
| JBIG2Decode (NOT IMPLEMETED - RETURN AN EXCEPTION) Decompresses data encoded using the JBIG2 standard, reproducing the original monochrome (1 bit per pixel) image data (or an approximation of that data). More...
|
|
static | decodeFilterDCTDecode ($data) |
| DCTDecode (NOT IMPLEMETED - RETURN AN EXCEPTION) Decompresses data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard, reproducing image sample data that approximates the original data. More...
|
|
static | decodeFilterJPXDecode ($data) |
| JPXDecode (NOT IMPLEMETED - RETURN AN EXCEPTION) Decompresses data encoded using the wavelet-based JPEG2000 standard, reproducing the original image data. More...
|
|
static | decodeFilterCrypt ($data) |
| Crypt (NOT IMPLEMETED - RETURN AN EXCEPTION) Decrypts data encrypted by a security handler, reproducing the data as it was before encryption. More...
|
|
static | Error ($msg) |
| Throw an exception. More...
|
|
|
static | $available_filters = array('ASCIIHexDecode', 'ASCII85Decode', 'LZWDecode', 'FlateDecode', 'RunLengthDecode') |
| Define a list of available filter decoders. More...
|
|
This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).
Definition at line 51 of file tcpdf_filters.php.
◆ decodeFilter()
static TCPDF_FILTERS::decodeFilter |
( |
|
$filter, |
|
|
|
$data |
|
) |
| |
|
static |
Decode data using the specified filter type.
- Parameters
-
$filter | (string) Filter name. |
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 79 of file tcpdf_filters.php.
References $data.
Referenced by TCPDF_PARSER\decodeStream().
81 case 'ASCIIHexDecode': {
82 return self::decodeFilterASCIIHexDecode(
$data);
85 case 'ASCII85Decode': {
86 return self::decodeFilterASCII85Decode(
$data);
90 return self::decodeFilterLZWDecode(
$data);
94 return self::decodeFilterFlateDecode(
$data);
97 case 'RunLengthDecode': {
98 return self::decodeFilterRunLengthDecode(
$data);
101 case 'CCITTFaxDecode': {
102 return self::decodeFilterCCITTFaxDecode(
$data);
105 case 'JBIG2Decode': {
106 return self::decodeFilterJBIG2Decode(
$data);
110 return self::decodeFilterDCTDecode(
$data);
114 return self::decodeFilterJPXDecode(
$data);
118 return self::decodeFilterCrypt(
$data);
122 return self::decodeFilterStandard(
$data);
◆ decodeFilterASCII85Decode()
static TCPDF_FILTERS::decodeFilterASCII85Decode |
( |
|
$data | ) |
|
|
static |
ASCII85Decode Decodes data encoded in an ASCII base-85 representation, reproducing the original binary data.
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 190 of file tcpdf_filters.php.
References $data, and array.
196 if (strpos(
$data,
'<~') !==
false) {
201 $eod = strpos(
$data,
'~>');
202 if ($eod !==
false) {
207 $data_length = strlen(
$data);
209 if (preg_match(
'/[^\x21-\x75,\x74]/',
$data) > 0) {
210 self::Error(
'decodeFilterASCII85Decode: invalid code');
213 $zseq = chr(0).chr(0).chr(0).chr(0);
217 $pow85 =
array((85*85*85*85), (85*85*85), (85*85), 85, 1);
218 $last_pos = ($data_length - 1);
220 for ($i = 0; $i < $data_length; ++$i) {
222 $char = ord(
$data[$i]);
224 if ($group_pos == 0) {
227 self::Error(
'decodeFilterASCII85Decode: invalid code');
231 $tuple += (($char - 33) * $pow85[$group_pos]);
232 if ($group_pos == 4) {
233 $decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8).chr($tuple);
241 if ($group_pos > 1) {
242 $tuple += $pow85[($group_pos - 1)];
245 switch ($group_pos) {
247 $decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8);
251 $decoded .= chr($tuple >> 24).chr($tuple >> 16);
255 $decoded .= chr($tuple >> 24);
259 self::Error(
'decodeFilterASCII85Decode: invalid code');
Create styles array
The data for the language used.
◆ decodeFilterASCIIHexDecode()
static TCPDF_FILTERS::decodeFilterASCIIHexDecode |
( |
|
$data | ) |
|
|
static |
ASCIIHexDecode Decodes data encoded in an ASCII hexadecimal representation, reproducing the original binary data.
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 150 of file tcpdf_filters.php.
References $data.
156 $eod = strpos(
$data,
'>');
157 if ($eod !==
false) {
163 $data_length = strlen(
$data);
164 if (($data_length % 2) != 0) {
170 self::Error(
'decodeFilterASCIIHexDecode: invalid code');
174 if (preg_match(
'/[^a-fA-F\d]/',
$data) > 0) {
175 self::Error(
'decodeFilterASCIIHexDecode: invalid code');
178 $decoded = pack(
'H*',
$data);
◆ decodeFilterCCITTFaxDecode()
static TCPDF_FILTERS::decodeFilterCCITTFaxDecode |
( |
|
$data | ) |
|
|
static |
CCITTFaxDecode (NOT IMPLEMETED - RETURN AN EXCEPTION) Decompresses data encoded using the CCITT facsimile standard, reproducing the original data (typically monochrome image data at 1 bit per pixel).
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 408 of file tcpdf_filters.php.
409 self::Error(
'~decodeFilterCCITTFaxDecode: this method has not been yet implemented');
◆ decodeFilterCrypt()
static TCPDF_FILTERS::decodeFilterCrypt |
( |
|
$data | ) |
|
|
static |
Crypt (NOT IMPLEMETED - RETURN AN EXCEPTION) Decrypts data encrypted by a security handler, reproducing the data as it was before encryption.
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 460 of file tcpdf_filters.php.
461 self::Error(
'~decodeFilterCrypt: this method has not been yet implemented');
◆ decodeFilterDCTDecode()
static TCPDF_FILTERS::decodeFilterDCTDecode |
( |
|
$data | ) |
|
|
static |
DCTDecode (NOT IMPLEMETED - RETURN AN EXCEPTION) Decompresses data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard, reproducing image sample data that approximates the original data.
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 434 of file tcpdf_filters.php.
435 self::Error(
'~decodeFilterDCTDecode: this method has not been yet implemented');
◆ decodeFilterFlateDecode()
static TCPDF_FILTERS::decodeFilterFlateDecode |
( |
|
$data | ) |
|
|
static |
FlateDecode Decompresses data encoded using the zlib/deflate compression method, reproducing the original text or binary data.
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 355 of file tcpdf_filters.php.
References $data.
357 $decoded = @gzuncompress(
$data);
358 if ($decoded ===
false) {
359 self::Error(
'decodeFilterFlateDecode: invalid code');
◆ decodeFilterJBIG2Decode()
static TCPDF_FILTERS::decodeFilterJBIG2Decode |
( |
|
$data | ) |
|
|
static |
JBIG2Decode (NOT IMPLEMETED - RETURN AN EXCEPTION) Decompresses data encoded using the JBIG2 standard, reproducing the original monochrome (1 bit per pixel) image data (or an approximation of that data).
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 421 of file tcpdf_filters.php.
422 self::Error(
'~decodeFilterJBIG2Decode: this method has not been yet implemented');
◆ decodeFilterJPXDecode()
static TCPDF_FILTERS::decodeFilterJPXDecode |
( |
|
$data | ) |
|
|
static |
JPXDecode (NOT IMPLEMETED - RETURN AN EXCEPTION) Decompresses data encoded using the wavelet-based JPEG2000 standard, reproducing the original image data.
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 447 of file tcpdf_filters.php.
448 self::Error(
'~decodeFilterJPXDecode: this method has not been yet implemented');
◆ decodeFilterLZWDecode()
static TCPDF_FILTERS::decodeFilterLZWDecode |
( |
|
$data | ) |
|
|
static |
LZWDecode Decompresses data encoded using the LZW (Lempel-Ziv-Welch) adaptive compression method, reproducing the original text or binary data.
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 274 of file tcpdf_filters.php.
References $data, and array.
278 $data_length = strlen(
$data);
281 for ($i = 0; $i < $data_length; ++$i) {
282 $bitstring .= sprintf(
'%08b', ord(
$data{$i}));
285 $data_length = strlen($bitstring);
291 $dictionary =
array();
292 for ($i = 0; $i < 256; ++$i) {
293 $dictionary[$i] = chr($i);
298 while (($data_length > 0) AND (($index = bindec(substr($bitstring, 0, $bitlen))) != 257)) {
300 $bitstring = substr($bitstring, $bitlen);
302 $data_length -= $bitlen;
310 $dictionary =
array();
311 for ($i = 0; $i < 256; ++$i) {
312 $dictionary[$i] = chr($i);
314 } elseif ($prev_index == 256) {
316 $decoded .= $dictionary[$index];
317 $prev_index = $index;
322 $decoded .= $dictionary[$index];
323 $dic_val = $dictionary[$prev_index].$dictionary[$index][0];
325 $prev_index = $index;
328 $dic_val = $dictionary[$prev_index].$dictionary[$prev_index][0];
329 $decoded .= $dic_val;
332 $dictionary[$dix] = $dic_val;
337 } elseif ($dix == 1023) {
339 } elseif ($dix == 511) {
Create styles array
The data for the language used.
◆ decodeFilterRunLengthDecode()
static TCPDF_FILTERS::decodeFilterRunLengthDecode |
( |
|
$data | ) |
|
|
static |
RunLengthDecode Decompresses data encoded using a byte-oriented run-length encoding algorithm.
- Parameters
-
$data | (string) Data to decode. |
- Since
- 1.0.000 (2011-05-23) static
Definition at line 371 of file tcpdf_filters.php.
References $data.
375 $data_length = strlen(
$data);
377 while($i < $data_length) {
379 $byte = ord(
$data{$i});
383 } elseif ($byte < 128) {
386 $decoded .= substr(
$data, ($i + 1), ($byte + 1));
392 $decoded .= str_repeat(
$data{($i + 1)}, (257 - $byte));
◆ decodeFilterStandard()
static TCPDF_FILTERS::decodeFilterStandard |
( |
|
$data | ) |
|
|
static |
Standard Default decoding filter (leaves data unchanged).
- Parameters
-
$data | (string) Data to decode. |
- Returns
- Decoded data string.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 138 of file tcpdf_filters.php.
References $data.
◆ Error()
static TCPDF_FILTERS::Error |
( |
|
$msg | ) |
|
|
static |
Throw an exception.
- Parameters
-
$msg | (string) The error message |
- Since
- 1.0.000 (2011-05-23) static
Definition at line 473 of file tcpdf_filters.php.
474 throw new Exception(
'TCPDF_PARSER ERROR: '.$msg);
◆ getAvailableFilters()
static TCPDF_FILTERS::getAvailableFilters |
( |
| ) |
|
|
static |
Get a list of available decoding filters.
- Returns
- (array) Array of available filter decoders.
- Since
- 1.0.000 (2011-05-23) static
Definition at line 67 of file tcpdf_filters.php.
Referenced by TCPDF_PARSER\decodeStream().
68 return self::$available_filters;
◆ $available_filters
TCPDF_FILTERS::$available_filters = array('ASCIIHexDecode', 'ASCII85Decode', 'LZWDecode', 'FlateDecode', 'RunLengthDecode') |
|
staticprivate |
Define a list of available filter decoders.
static
Definition at line 57 of file tcpdf_filters.php.
The documentation for this class was generated from the following file: