0

I have a problem when extract arabic text from pdf.
I use PdfToText library
The text appears in this figure (΋ΎϬϧϟ΍υϔΣϟ΍ΦϳέΎΗ ΏϟΎρϟ΍ϡϳΩϘΗΝΫϭϣϧ ΩϳϘϟ΍ϡϗέ) How can i solve it ? i tried

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
but this did not solve my problem
  • I'm unsure but it could be an encoding issue - have you tested it with plain English PDF? – James Mar 19 '18 at 16:10
  • yes i tested it in english pdf and it works well but in arabic pdf didn't work – Ahmed Mahmoud Mar 19 '18 at 16:12
  • I've never used it and unsure if it's open source to download once registered but perhaps this could help? http://arabicpdf.com/PdfDebugger/ – James Mar 19 '18 at 16:15

1 Answers1

0

English letters are part of basic ASCII char set so the output is usually without any problems however any other languages using various accents or even different letters, ie. Arabic, Azbuka, Greek, etc. uses letters out of the basic set.

Make sure all three sources are using same encoding:

  1. all the PHP scripts generating the output
  2. the HTML encoding meta tag
  3. the output file as well

ad 1
Check your editor how it saves the PHP scripts to the file system. The way how to set it up differs from each editor

ad 2 Use HTML meta tag <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

ad 3 define the encoding to use UTF-8 for example: pdftotext -enc UTF-8 your.pdf. According to the documentation the PdfToText class generates UTF8-encoded text.

ino
  • 2,345
  • 1
  • 15
  • 27