Text parsing returns garbage
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.7k
- Forks
- 579
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
Hello,
I've tried to parse this PDF from the samples/bugs folder of the repo.
Using the code you provided :
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile($file);
return $pdf->getText();
I got this :
24
$/*\(0\(1
0RGHOGRRUGH5DDGYRRU2QURHUHQGH=DNHQ52=RSMXOLYDVWJHVWHOGHQRSMXOLJHGHSRQHHUGELMGHJULIILHYDQGHUHFKWEDQNWH'HQ
+DDJHQDOGDDULQJHVFKUHYHQRQGHUQXPPHU,HGHUHDDQVSUDNHOLMNKHLGYRRUQDGHOLJHJHYROJHQYDQKHWJHEUXLNYDQGHWHNVWYDQKHWPRGHO
ZRUGWGRRUGH52=XLWJHVORWHQ
*
\024\021\024+XXUGHU GLHQW KHW JHKXXUGH JHGXUHQGH GH JHKHOH GXXU YDQ GH RYHUHHQNRPVW GDDGZHUNHOLMN EHKRRUOLMN HQ ]HOI WH
JHEUXLNHQ XLWVOXLWHQG RYHUHHQNRPVWLJ GH LQ GH KXXURYHUHHQNRPVW DDQJHJHYHQ EHVWHPPLQJ HQ PHW LQDFKWQHPLQJ YDQ
EHVWDDQGH EHSHUNWH UHFKWHQ HQ GH YDQ RYHUKHLGVZHJH EUDQGZHHU HQ GH QXWVEHGULMYHQ JHVWHOGH RI QRJ WH VWHOOHQ HLVHQ
WHQ DDQ]LHQ YDQ KHW JHEUXLN YDQ KHW JHKXXUGH 2QGHU QXWVEHGULMYHQ ZRUGW WHYHQVYHUVWDDQVRRUWJHOLMNHEHGULMYHQGLH]LFK
EH]LJKRXGHQ PHW GH OHYHULQJ KHW WUDQVSRUW HQ GH PHWLQJ YDQ KHW YHUEUXLN YDQ HQHUJLH ZDWHU HQ GHUJHOLMNH 7HQ]LM HU ELM
DDQYDQJ YDQ GH KXXURYHUHHQNRPVW VSUDNH LV YDQ YHUKXXU YDQ JHVWRIIHHUGH HQRI JHPHXELOHHUGH ZRRQUXLPWH GLHQW
KXXUGHU KHW JHKXXUGH ELM DDQYDQJ YDQ GH KXXU WH VWRIIHUHQ HQ WH PHXELOHUHQ +XXUGHU ]DO KHW JHKXXUGH YROGRHQGH
JHVWRIIHHUGHQJHPHXELOHHUGKRXGHQ
\024\021\025+XXUGHU
Which is obviously wrong. Am I missing something (encoding) ? Or is this a bug from the library ?
Thanks !
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
Reproduce the report using the PDF linked in the issue and the sample location samples/bugs, starting with Parser->parseFile() and getText(). Compare the extracted output with the document’s visible text and investigate whether the character encoding is handled correctly. Done means the document produces readable text or the limitation is clearly confirmed and covered by an appropriate regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100