smalot / smalot/pdfparser

Problems to extract text from a PDF/A file

Open
#289 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

For machine learning purposes (php-ml), I need to extract the raw text from lots of PDF files.

But unfortunately, for few of them, I was unable to get the text because they are using "stream" on their pdf source, like this one.

<?php

include 'vendor'.DIRECTORY_SEPARATOR.'autoload.php';

// Parse pdf file and build necessary objects.
$parser = new \Smalot\PdfParser\Parser();
$pdf    = $parser->parseFile('pdfa.pdf');
 
$text = $pdf->getText();
echo $text;

The result is something like this:

https://i.imgur.com/xa8GBjS.png

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 report with the linked PDF/A file and the shown Parser::parseFile() and getText() calls. Inspect how the parser handles PDF streams and compare the extracted result with the source document. Done means the reported PDF/A file yields its raw text without breaking existing parsing behavior.

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.