smalot / smalot/pdfparser

Strange chararacters while parsing PDF

Open
#654 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

  • PHP Version: 8.2
  • PDFParser Version: 3 (the last from github)
Description:

Hello
Very strange characters are returned by parsing bank detail PDF

PDF input

Releve_compte_31_10_2016-1.pdf

Expected output & actual output

[22-Nov-2023 15:48:38 Europe/Paris] $config: Smalot\PdfParser\Config Object
(
[fontSpaceLimit:Smalot\PdfParser\Config:private] => -50
[horizontalOffset:Smalot\PdfParser\Config:private] =>
[pdfWhitespaces:Smalot\PdfParser\Config:private] =>
[22-Nov-2023 15:48:38 Europe/Paris] $metaData: Array
(
[Author] => QIJS
[CreationDate] => 2016-11-01T16:10:42+00:00
[Creator] => IBM i program CBFEXPO/B0203P
[ModDate] => 2019-01-14T10:59:15+01:00
[Producer] => 2A55SAM Spool-a-Matic by Gumbo Software Inc V2R7M0
[Subject] => B0203PPR
[Pages] => 3
[dc:format] => application/pdf
[dc:creator] => QIJS
[dc:description] => B0203PPR
[xmp:createdate] => 2016-11-01T16:10:42
[xmp:creatortool] => IBM i program CBFEXPO/B0203P
[xmp:modifydate] => 2019-01-14T10:59:15+01:00
[xmp:metadatadate] => 2019-01-14T10:59:15+01:00
[pdf:producer] => 2A55SAM Spool-a-Matic by Gumbo Software Inc V2R7M0
[xmpmm:documentid] => uuid:a93675b5-9dae-584d-baf5-106a071e6cfc
[xmpmm:instanceid] => uuid:a8b43f68-a150-464b-94ce-f5079011be95
)

[22-Nov-2023 15:48:38 Europe/Paris] Number of pages : 3
[22-Nov-2023 15:48:38 Europe/Paris] $text: ŧ£™‰£@„…@¥–£™…@ƒ–”—£…@…•
ÅäÙ
M×™–£À‡À@—™@“@ǁ™•£‰…@„…¢@ÄÀ—Ë£¢K@¦¦¦K‡™•£‰…„…¢„…—–£¢K†™]
@ÂÖäÙâÖÙÁÔÁ@ÅââÅÕãÉÅÓ@×Óäâ
@@@@ñ
ÔÙ@Öä@ÔÔÅ@ÅÔÔÁÕäÅÓ@ÂÙÖÃÈÖã
ñô@ÙäÅ@âÅÇäÉÅÙ
×ÁÙÉâ
÷õððö@×ÁÙÉâ
@ñaññaòðñö ôðöñøøðòöóðððôðò÷ôöõø ñõÅäÙ @ñañðaòðñö óñañðaòðñö@@@@ñKðððkðð@Ÿ @@ðkðððððð@l@@@ñ
ÂÖäâÆÙ××ççç ÆÙ÷öôðöñøøðòöóðððôðò÷ôöõøñõ
ÔÖäåÅÔÅÕãâ@ÅÕ@ÅäÙ
âÖÓÄÅ@Áä@z óðaðùaòðñö @@@@@@@@@@@@ñKöòñkóö
@óañðaòðñö Ù…“…¥À@„‰††À™À@Á™£…@ôù÷ù\\ö÷ôñ @óañðaòðñö@@@@@@@@@ñKõðøkôó
@óañðaòðñö Ù…“…¥À@„‰††À™À@Á™£…@ôù÷ù\\ùñøù @óañðaòðñö@@@@@@@@@@@ô÷ökõø
@óañðaòðñö Ù…“…¥À@„‰††À™À@Á™£…@ôù÷ù\\ùñøù @óañðaòðñö@@@@@@@@@@@@@ùkùù

Code

My code :
// Parse PDF file and build necessary objects.
$parser = new Parser();
$pdf = $parser->parseFile($pdf_file_name);
$config = $parser->getConfig();
error_log(' $config: '.print_r( $config, true ) );

$metaData = $pdf->getDetails();
error_log(' $metaData: '.print_r( $metaData, true ) );

$pages = $pdf->getPages();
$nb_pages = sizeof( $pages );
error_log('Number of pages : '.$nb_pages );

$text = $pdf->getText();
error_log(' $text: '.print_r( $text, true ) );

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

Reproduce the issue with the attached Releve_compte_31_10_2016-1.pdf using the shown Parser::parseFile() and getText() entry points. Inspect how this PDF's text is decoded and compare the returned characters with the document; done means the extracted text is readable without breaking existing PDF 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.