Open LivraghiFrancesco opened 6 years ago
I'have fixed the problem in a more elegant way.
In ...protected function getRawObject(... from line 807
change:
// hexadecimal string object $objtype = PDF_TYPE_HEX; ++$offset; // The "Panose" entry in the FontDescriptor Style dict seems to have hex bytes separated by spaces. if (($char == '<') AND (preg_match('/^([0-9A-Fa-f ]+)[>]/iU', substr($data, $offset), $matches) == 1)) { $objval = $matches[1]; $offset += strlen($matches[0]); unset($matches); }
to
// hexadecimal string object $objtype = PDF_TYPE_HEX; ++$offset; // The "Panose" entry in the FontDescriptor Style dict seems to have hex bytes separated by spaces. if (($char == '<') AND (preg_match('/^([0-9A-Fa-f ]+)[>]/iU', substr($data, $offset), $matches) == 1)) { $objval = $matches[1]; $offset += strlen($matches[0]); } else if (($char == '<') AND ($endpos = strpos($this->pdfdata, '>', $offset)) !== FALSE) { $objval = substr($data, $offset,$endpos-$offset+1); $offset = $endpos + 1; } unset($matches);
Thanks, and best regards Francesco
Dear Paul, the parser crashes because it is not able to parse correctly this kind of PDF objects:
`.. 4 0 obj [/Indexed 75 0 R 255 <000000 010101 020202 030303 040404 050505 060606 070707 080808 090909 0A0A0A 0B0B0B 0C0C0C 0D0D0D 0E0E0E 0F0F0F 101010 111111 121212 131313 141414 151515 161616 171717 181818 191919 1A1A1A 1B1B1B 1C1C1C 1D1D1D 1E1E1E 1F1F1F 202020 212121 222222 232323 242424 252525 262626 272727 282828 292929 2A2A2A 2B2B2B 2C2C2C 2D2D2D 2E2E2E 2F2F2F 303030 313131 323232 333333 343434 353535 363636 373737 383838 393939 3A3A3A 3B3B3B 3C3C3C 3D3D3D 3E3E3E 3F3F3F 404040 414141 424242 434343 444444 454545 464646 474747 484848 494949 4A4A4A 4B4B4B 4C4C4C 4D4D4D 4E4E4E 4F4F4F 505050 515151 525252 535353 545454 555555 565656 575757 585858 595959 5A5A5A 5B5B5B 5C5C5C 5D5D5D 5E5E5E 5F5F5F 606060 616161 626262 636363 646464 656565 666666 676767 686868 696969 6A6A6A 6B6B6B 6C6C6C 6D6D6D 6E6E6E 6F6F6F 707070 717171 727272 737373 747474 757575 767676 777777 787878 797979 7A7A7A 7B7B7B 7C7C7C 7D7D7D 7E7E7E 7F7F7F 808080 818181 828282 838383 848484 858585 868686 878787 888888 898989 8A8A8A 8B8B8B 8C8C8C 8D8D8D 8E8E8E 8F8F8F 909090 919191 929292 939393 949494 959595 969696 979797 989898 999999 9A9A9A 9B9B9B 9C9C9C 9D9D9D 9E9E9E 9F9F9F A0A0A0 A1A1A1 A2A2A2 A3A3A3 A4A4A4 A5A5A5 A6A6A6 A7A7A7 A8A8A8 A9A9A9 AAAAAA ABABAB ACACAC ADADAD AEAEAE AFAFAF B0B0B0 B1B1B1 B2B2B2 B3B3B3 B4B4B4 B5B5B5 B6B6B6 B7B7B7 B8B8B8 B9B9B9 BABABA BBBBBB BCBCBC BDBDBD BEBEBE BFBFBF C0C0C0 C1C1C1 C2C2C2 C3C3C3 C4C4C4 C5C5C5 C6C6C6 C7C7C7 C8C8C8 C9C9C9 CACACA CBCBCB CCCCCC CDCDCD CECECE CFCFCF D0D0D0 D1D1D1 D2D2D2 D3D3D3 D4D4D4 D5D5D5 D6D6D6 D7D7D7 D8D8D8 D9D9D9 DADADA DBDBDB DCDCDC DDDDDD DEDEDE DFDFDF E0E0E0 E1E1E1 E2E2E2 E3E3E3 E4E4E4 E5E5E5 E6E6E6 E7E7E7 E8E8E8 E9E9E9 EAEAEA EBEBEB ECECEC EDEDED EEEEEE EFEFEF F0F0F0 F1F1F1 F2F2F2 F3F3F3 F4F4F4 F5F5F5 F6F6F6 F7F7F7 F8F8F8 F9F9F9 FAFAFA FBFBFB FCFCFC FDFDFD FEFEFE FFFFFF
I have fixed it (only to avoid the crash) changing the **protected function getRawObject() from line 851 adding a check for an hypotetical fixed string object.
default: if (preg_match('/^([0-9]+)[\s]+([0-9]+)[\s]+([Robj]{1,3})/i', substr($data, $offset, 33), $matches) == 1) { if ($matches[3] == 'R') { // indirect object reference $objtype = PDF_TYPE_OBJREF; $offset += strlen($matches[0]); $objval = array(intval($matches[1]), intval($matches[2])); } elseif ($matches[3] == 'obj') { // object start $objtype = PDF_TYPE_OBJECT; $objval = intval($matches[1]).'_'.intval($matches[2]); $offset += strlen ($matches[0]); } } elseif (($numlen = strspn($data, '0123456789ABCDEF', $offset)) > 0) { // fixed string object if ($numlen == 6) { $objval = substr($data, $offset, $numlen); $objtype = PDF_TYPE_STRING; $offset += 6; } elseif (($numlen = strspn($data, '+-.0123456789', $offset)) > 0) { // numeric object $objval = substr($data, $offset, $numlen); $objtype = (intval($objval) != $objval) ? PDF_TYPE_REAL : PDF_TYPE_NUMERIC; $offset += $numlen; } } elseif (($numlen = strspn($data, '+-.0123456789', $offset)) > 0) { // numeric object $objval = substr($data, $offset, $numlen); $objtype = (intval($objval) != $objval) ? PDF_TYPE_REAL : PDF_TYPE_NUMERIC; $offset += $numlen; } unset($matches); break;
Best regards Francesco