smalot / smalot/pdfparser

Trouble parsing a document

Open
#643 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

  • PHP Version: 7.4
  • PDFParser Version: 2.7
Description:

I'm attempting to parse a document that is primarily tables. Most of the text is a jumble with white space and newlines missing in various places.

PDF input

I would like to provide a sample PDF if there's a way for me to change the text to remove private information.

Expected output & actual output

Here's an example of one of the headers:

Expected

ITEM ID    DESCRIPTION    SERVICE PERIOD    EXTENDED PRICE    TAX    LINE TOTAL

Actual

ITEM ID DESCRIPTIONSERVICE PERIOD       EXTENDED  PRICETAXLINE TOTAL
Code
    $config = new \Smalot\PdfParser\Config();
    
    // Initialize and load PDF Parser library 
    $parser = new \Smalot\PdfParser\Parser([], $config); 

    // Parse pdf file using Parser library 
    $pdf = $parser->parseFile($Filename); 
     
    // Extract text from PDF 
    $textContent = $pdf->getText();
    
    print($textContent);

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 with the PHP example that constructs Parser and calls parseFile(), then compare getText() with the expected and actual table header shown in the issue. A sanitized sample PDF and complete PHP and PDFParser patch versions are needed to reproduce the whitespace and newline loss; done means the behavior is reproducible and its cause is identified.

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.