Incorrect parsing, get empty text
Open
Nobody has claimed this yet.
bug
parsing fail
- Dominant language
- PHP
- Stars
- 2.7k
- Forks
- 579
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
- PHP Version: 8.1.2
- PDFParser Version: 2.7
Description:
PDF input
https://cdn.yinyuezhushou.com/static/7d38770d31c3cd66219eaa1b7959e2dd.pdf
Expected output & actual output
Expected output: the text in file
Code
try {
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile($path);
$text = $pdf->getText();
return preg_replace('/\s+/', '', $text);
} catch (Exception $e) {
$logger = self::getLogger('pdf2text');
$logger->warning($e->getMessage(), ['path' => $path]);
return '';
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied PHP example with the linked PDF, using Parser::parseFile() and then getText(), and compare the result with the PDF's visible text. Investigate the parsing path that handles this input and add a focused reproduction test if the project provides a suitable test location. Done means the linked PDF no longer produces empty extracted text while existing parsing behavior remains intact.
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
- 30/100