smalot / smalot/pdfparser

File parsed returns unreadable text

Open
#246 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Thank you for the awesome Pdfparser library, it really helps me a lot with my projects, and use it quite often recently..
But I found a difficulty with my last project which was my pdf file was converted into some unreadable format text instead of plain text..
My friend told me I should do something with the encoding, but I'm not really sure..
So, I would really glad if anybody can give me some hint or idea if I missing something or it was indeed a bug from the library..
I've tried to parse it as a whole and by each pages btw, it was still not working..
notconverted

Here is my code,

$PdfParser = new \Smalot\PdfParser\Parser();
$pdf = $PdfParser->parseFile($file);
$text -> getText();
echo $text;

And this is what it returns,

                                  JHGSA IUYSHJG st  GUH  st  GUH HUYGAH st  JHGSA  st  st  tt t t  ss1 ss2 t   21666        ! "  # ssst   # t t  #t  #ss1  #ss2 $# $     t%&t '(# t t  2$# t   $$ss t 2$   2$'(# t 2$$ss t t%&t ' # tt ts !"#$  tt $$ss   2$$ss ) tst   t" + t  t$   ) t ttst  ," 1st$'(# t #s%(  t t   ) t $t   t st   tss1 ,  )$   %' #  ' # t$st HUYGAH IUYSHJG               #$#$ %#$# %  "t-." s   ) t$# ) t$'(# t $s(%$ " t%&t  tt t 1st$ %$ss  tt  tt%&t  tt%&t ss/%$ss t )$$ss t )$'(# t %%'0t+#1 2 sst t1 ) tst  ) t$$ss  t t%&t  t t ts )$# ,"  t%&t   ! "#$"#%!&   !"#"#%!& !"#"#%!&    ! ' ' ( )Y  !  Z ,-.                                     JHGSA IUYSHJG   GUH HUYGAH  # sst t ss% tt# ) t t t ) t, ) t   ) t ($  '3st  t   % #   ts%'1 ) t*#t  /% t$ss t tt%&t & tt(%  & t-t ts  tt ) tt  2$ %$ss ) tss2 ) t' # t$st 2$ t t%$ss 1st$$ss"tt  t    ) t$$ss"tt  t$ %$ss  t$$ss t s $t% t   ) t%&t )$$ss )$ %$ss )$ t t%$ss  $   t' ss ss/% t  ' ss IUYSHJG&  ' ss$ %%t1  tss4t  tss5st   tss5  tss5t  tss51  tss52 ' # tst  t' # tt ts  ) t' st  t$% "  tt+ t% " st%&t s&t t sss st sst  st ! //$01$1% ) 2 (2 ) 2 () 31!#%%#% !"#"#%!& !"#"#%!& &$4$04%%%%  ' ' ! &$4$04%%%%   !"#$"#%!&   !"#"#%!& !"#"#%!&    ! ' ' ( )Y  #  Z ,-.

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 report with the supplied PHP snippet, the affected PDF, and the parseFile/getText flow. Inspect how this PDF's encoded text is handled and determine whether the output can be returned as readable plain text; the issue is done when the behavior is corrected or the limitation is clearly established.

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.