smalot / smalot/pdfparser

TCPDF_PARSER ERROR: Invalid object reference: Array

Open
#86 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
2.7k
Forks
579
Avg merge
2m
Merged PRs (30d)
1

Description

Context: smalot/pdfparser v0.9.25, tecnickcom/tcpdf 6.2.12, PHP 5.4.6.0; Windows 10 (64 x64).

Hi
We are unable to process any pdf file. We tested with the demo page (http://www.pdfparser.org/demo) and it parses OK. But when we try
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile($pdf_file_path);
it always fails with the following error:
PHP Fatal error: Uncaught exception 'Exception' with message 'TCPDF_PARSER ERROR: Invalid object reference: Array' in T:\Projecto\PHP\PDF_parsing\PDFParser\vendor\tecnickcom\tcpdf\tcpdf_parser.php:807
Stack trace:
#0 T:\Projecto\PHP\PDF_parsing\PDFParser\vendor\tecnickcom\tcpdf\tcpdf_parser.php(680): TCPDF_PARSER->Error('Invalid object ...')
#1 T:\Projecto\PHP\PDF_parsing\PDFParser\vendor\tecnickcom\tcpdf\tcpdf_parser.php(286): TCPDF_PARSER->getIndirectObject('', '173', true)
#2 T:\Projecto\PHP\PDF_parsing\PDFParser\vendor\tecnickcom\tcpdf\tcpdf_parser.php(195): TCPDF_PARSER->decodeXrefStream('173', Array)
#3 T:\Projecto\PHP\PDF_parsing\PDFParser\vendor\tecnickcom\tcpdf\tcpdf_parser.php(117): TCPDF_PARSER->getXrefData()
#4 T:\Projecto\PHP\PDF_parsing\PDFParser\vendor\smalot\pdfparser\src\Smalot\PdfParser\Parser.php(88): TCPDF_PARSER->__construct('%PDF-1.3?%?????...')
#5 T:\Projecto\PHP\PDF_parsing\PDFParser\vendor\smalot\pdfparser\src\Smalot\PdfParser\Parser.php(74): Smalot\PdfParser\Parser->parseContent('%PDF-1.3?%?????...') in T:\Projecto\PHP\PDF_parsing\PDFParser\vendor\tecnickcom\tcpdf\tcpdf_parser.php on line 807

Could you help?
Thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the reported PHP, smalot/pdfparser, and TCPDF versions using the affected PDF; no PDF is attached, so obtaining a reproducible file is necessary. Read tcpdf_parser.php around lines 807, 680, 286, and 195, then follow the call from src/Smalot/PdfParser/Parser.php lines 74 and 88. Done means the affected PDF parses without the invalid object reference and the regression is covered by a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.