Problems with getText() on PDF documents with UTF16BE encoding
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.7k
- Forks
- 579
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
- PHP Version: 8.2
- PDFParser Version: 2.11.0
Description:
PDF input
There is a file attached to a bug report of pdftotext https://gitlab.freedesktop.org/poppler/poppler/-/issues/332
Expected output & actual output
The getText() output returns mostly utf16 encoding text, but it seems like there were non utf16 chars added by the parser.
Besides that, I wonder if there is any way to determine which encoding is use? Or maybe, can the parser do a conversion to utf8?
Code
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile($infile);
$t = $pdf->getText();
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 reproducing the report with the attached 2004.pdf, PHP 8.2, PDFParser 2.11.0, and the shown Parser::parseFile() and getText() calls. Compare the returned text with the PDF content and investigate how encoding is detected or converted; the issue does not identify a file or test, and the expected behavior needs clarification.
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