Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninitialized string offset: 548 #43

Open
Hecke29 opened this issue Jan 8, 2020 · 3 comments
Open

Uninitialized string offset: 548 #43

Hecke29 opened this issue Jan 8, 2020 · 3 comments

Comments

@Hecke29
Copy link

Hecke29 commented Jan 8, 2020

When I try to merge PDFs with the following code I get the error Notice: Uninitialized string offset: 548

$merger = new Merger(new TcpdiDriver());
$merger->addIterator([new File('354025a5-original.pdf', true), new File('another.pdf', true)]);
$mergedPdf = $merger->merge();

This happens when trying to merge the attached PDF File
354025a5-original.pdf

More stack:

Notice: Uninitialized string offset: 548
--
in tcpdi_parser.php line 711
at tcpdi_parser->getRawObject(548, '/NumberofPages 1/PageWidthList<</0 841.89>>/DocumentID<FEFF0078006D0070002E006400690064003A00360065006500660036006600380036002D0030003000300035002D0034003700620063002D0061003000350031002D003600330030003500640065003300300061003100650034>/OriginalDocumentID<FEFF0078006D0070002E006400690064003A00620065006200360061003800380062002D0030003100640063002D0034003200330038002D0039003300350037002D006300370036006300360037003400300062003200660030>/PageUIDList<</0 3650>>/LastModified<FEFF0044003A00320030003100390031003200310038003100300030003500330036005A>>')in tcpdi_parser.php line 916
at tcpdi_parser->getDictValue(559, '/InDesign<</NumberofPages 1/PageWidthList<</0 841.89>>/DocumentID<FEFF0078006D0070002E006400690064003A00360065006500660036006600380036002D0030003000300035002D0034003700620063002D0061003000350031002D003600330030003500640065003300300061003100650034>/OriginalDocumentID<FEFF0078006D0070002E006400690064003A00620065006200360061003800380062002D0030003100640063002D0034003200330038002D0039003300350037002D006300370036006300360037003400300062003200660030>/PageUIDList<</0 3650>>/LastModified<FEFF0044003A00320030003100390031003200310038003100300030003500330036005A>>>>')in tcpdi_parser.php line 798
at tcpdi_parser->getRawObject(9, '/InDesign<</NumberofPages 1/PageWidthList<</0 841.89>>/DocumentID<FEFF0078006D0070002E006400690064003A00360065006500660036006600380036002D0030003000300035002D0034003700620063002D0061003000350031002D003600330030003500640065003300300061003100650034>/OriginalDocumentID<FEFF0078006D0070002E006400690064003A00620065006200360061003800380062002D0030003100640063002D0034003200330038002D0039003300350037002D006300370036006300360037003400300062003200660030>/PageUIDList<</0 3650>>/LastModified<FEFF0044003A00320030003100390031003200310038003100300030003500330036005A>>>>')in tcpdi_parser.php line 916
at tcpdi_parser->getDictValue(848, '/BleedBox[ 0 0 841.89 595.276]/Resources<</ColorSpace<</CS0 8 0 R >>/XObject<</Im0 10 0 R >>/ExtGState<</GS0 9 0 R >>/ProcSet[/PDF/ImageC/ImageI]>>/MediaBox[ 0 0 841.89 595.276]/TrimBox[ 0 0 841.89 595.276]/Type/Page/Parent 3 0 R /Contents 7 0 R /CropBox[ 0 0 841.89 595.276]/PieceInfo<</InDesign<</NumberofPages 1/PageWidthList<</0 841.89>>/DocumentID<FEFF0078006D0070002E006400690064003A00360065006500660036006600380036002D0030003000300035002D0034003700620063002D0061003000350031002D003600330030003500640065003300300061003100650034>/OriginalDocumentID<FEFF0078006D0070002E006400690064003A00620065006200360061003800380062002D0030003100640063002D0034003200330038002D0039003300350037002D006300370036006300360037003400300062003200660030>/PageUIDList<</0 3650>>/LastModified<FEFF0044003A00320030003100390031003200310038003100300030003500330036005A>>>>>>')in tcpdi_parser.php line 798
at tcpdi_parser->getRawObject(285, '/BleedBox[ 0 0 841.89 595.276]/Resources<</ColorSpace<</CS0 8 0 R >>/XObject<</Im0 10 0 R >>/ExtGState<</GS0 9 0 R >>/ProcSet[/PDF/ImageC/ImageI]>>/MediaBox[ 0 0 841.89 595.276]/TrimBox[ 0 0 841.89 595.276]/Type/Page/Parent 3 0 R /Contents 7 0 R /CropBox[ 0 0 841.89 595.276]/PieceInfo<</InDesign<</NumberofPages 1/PageWidthList<</0 841.89>>/DocumentID<FEFF0078006D0070002E006400690064003A00360065006500660036006600380036002D0030003000300035002D0034003700620063002D0061003000350031002D003600330030003500640065003300300061003100650034>/OriginalDocumentID<FEFF0078006D0070002E006400690064003A00620065006200360061003800380062002D0030003100640063002D0034003200330038002D0039003300350037002D006300370036006300360037003400300062003200660030>/PageUIDList<</0 3650>>/LastModified<FEFF0044003A00320030003100390031003200310038003100300030003500330036005A>>>>>>')in tcpdi_parser.php line 916
...

Even more stack available if necessary.
How can I challenge this problem? Is that tcpdi_parser even maintained by you?

@Hecke29
Copy link
Author

Hecke29 commented Jan 8, 2020

An dirty

        while (!isset($data{$offset})) {
            $offset-=2;
        }

in tcpdi_parser works.
Will look into how to make this "cleaner".

@hanneskod
Copy link
Owner

Hi! And thanx for reporting!

No I'm not maintaining it actually. I put it in the source because no one seems to be maintaining anything and I needed to make some minor fixes for php 7.4.. If you have found a more official version that works I'm happy to use that instead. Otherwise I'll merge any fix as long as there are some additional tests. I can write an acceptance test with your failing file if you want something to hack against..

@guianzollin
Copy link

guianzollin commented Oct 28, 2022

I'm havig this same issue in some cases of merge.

I removed the try/catch statement to see where it came from.

Uninitialized string offset: 22 {"userId":1,"exception":"\[object\] (ErrorException(code: 0): Uninitialized string offset: 22 at .../vendor/iio/libmergepdf/tcpdi/tcpdi_parser.php:711)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants