smalot / smalot/pdfparser

Incorrect parsing, get empty text

Open
#658 2 comments 0 reactions 0 assignees View on GitHub

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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.