Skip to content

Illegal string offset warnings #24

@tommynovember7

Description

@tommynovember7

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.

return $obj;

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.

#23

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions