tcpdi_parser icon indicating copy to clipboard operation
tcpdi_parser copied to clipboard

Illegal string offset warnings

Open tommynovember7 opened this issue 7 years ago • 3 comments

If a pdf has such an object like the followings, tcpdf_parser fails to continue parsing the data.

2 0 obj
<< /Type /Page % 1
   /Parent 1 0 R
   /MediaBox [ 0 0 839.314286 1186.971429 ]
   /Contents 4 0 R
   /Group <<
      /Type /Group
      /S /Transparency
      /I true
      /CS /DeviceRGB
   >>
   /Resources 3 0 R
>>

getRawObject() is expected to return an array which contains an object and its offset, but it currently returns an object without its offset if the pdf has % comments. It causes Illegal string offset warnings.

https://github.com/pauln/tcpdi_parser/blob/c7c3e86cd1a15c293ae8246d32caaae3e8b27db6/tcpdi_parser.php#L725

I've created a compact example. Would you please check it? tcpdi_parser_issue.tar.gz

$ ls
sample.php	source.pdf	tcpdi_parser
$ php sample.php
PHP Warning:  Illegal string offset 'Parffo' in /Users/lancelot/Sandbox/PHP/tcpdi_parser_issue/tcpdi_parser/tcpdi_parser.php on line 712
PHP Warning:  Illegal string offset 'Parffp' in /Users/lancelot/Sandbox/PHP/tcpdi_parser_issue/tcpdi_parser/tcpdi_parser.php on line 712
PHP Warning:  Illegal string offset 'Parffq' in /Users/lancelot/Sandbox/PHP/tcpdi_parser_issue/tcpdi_parser/tcpdi_parser.php on line 712
...

Additionally, I've created a PR. I'll be grateful if you'd review it.

https://github.com/pauln/tcpdi_parser/pull/23

tommynovember7 avatar Jul 30 '18 05:07 tommynovember7

I have the same problem. Did you find a solution?

mrpamacs avatar Jun 04 '19 11:06 mrpamacs

@mrpamacs Actually I already created the PR for the issue, but it still haven't been merged. You might want to fork the repository and apply that change If you want to resolve the issue as soon as possible.

tommynovember7 avatar Jun 05 '19 01:06 tommynovember7

Some PDF files TCPDI cannot read image

brunobmorais avatar Jul 17 '20 11:07 brunobmorais