Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5868

PDFBox not extracting text of non-latin languages(tamil, bengali) properly but adobe reader's save as text does

    XMLWordPrintableJSON

Details

    Description

      I downloaded the latest executable jar of pdfbox (3.0.3) for testing and used the export:text command line tool to obtain the results

      • the multilingual_test.pdf is the original pdf i made to test multilingual text extraction.
      • the pdfbox_out.txt is the text file produced by pdfbox
      • the adobe_out.txt is the text file created by adobe reader's save as text feature

       

      Observation:

      as you can see in the attachment the text file obtained by pdfbox shows weird unicodes for tamil and bengali (for hindi the charecters are extracted but not overlapped; japanese seems fine to me). in contrast the text file file obtained from adobe reader's save as text feature seems fine and copy pasting the text from my document viewer(evince) also works.

      Questions:

      1. why are the outputs from pdfbox and adobe different?
      2. what can i do to extract the text from a multilingual pdf correctly?
      3. Is there a way to apply pattern matching to text in pdf file and declare matches without extracting the text first? (say if the problem is with fonts and glyphs)

      My Usecase fyi:

      i am trying to extract text from files and run pattern matching. I am using apache tika for parsing documents. I noticed problem with extracted PDF text (other filetypes parse fine). used executable pdfbox jar to conclude that the problem is in pdfbox and not in tika. tested with adobe reader's extract text to confirm the problem is not with the pdf. i  want to extract these multilingual text to run pattern matching on them alone and do not need to display the content but only if the pattern is present or not (say if the problem is with fonts and glyphs)

       

      Attachments

        1. multilingual_test.pdf
          85 kB
          Manish S N
        2. adobe_out.txt
          4 kB
          Manish S N
        3. pdfbox_out.txt
          4 kB
          Manish S N
        4. screenshot-1.png
          73 kB
          Tilman Hausherr
        5. okular_out.txt
          4 kB
          Manish S N
        6. poppler_out.txt
          4 kB
          Manish S N
        7. Main.java
          0.7 kB
          Manish S N
        8. Tilman's_solution_out.txt
          4 kB
          Manish S N
        9. screenshot-2.png
          19 kB
          Tilman Hausherr
        10. suppressDuplicateOverlapping_out.txt
          4 kB
          Manish S N
        11. PDFBOX-5868-SI5K4X4Z55SQAUPLAUP6QRRWT3UD3LAA-EmptyActualText_reduced.pdf
          9 kB
          Tilman Hausherr
        12. PDFBOX-5868-7FHMU2HNOUUPENUPKZDGD2V65YEVABRS-EmptyActualText.pdf
          315 kB
          Tilman Hausherr
        13. PDFBOX-5868-SI5K4X4Z55SQAUPLAUP6QRRWT3UD3LAA-EmptyActualText.pdf
          123 kB
          Tilman Hausherr
        14. image-2024-08-19-10-38-13-472.png
          10 kB
          Manish S N
        15. EmptyActualText_poppler.txt
          2 kB
          Manish S N
        16. EmptyActualText_reduced_poppler.txt
          0.0 kB
          Manish S N
        17. content_diffs_with_exceptions-ActualText.xlsx
          1.62 MB
          Tilman Hausherr
        18. page.pdf
          124 kB
          Manish S N
        19. image-2024-08-30-17-55-41-423.png
          6 kB
          Manish S N

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              manish003 Manish S N
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: