Skip to content

Commit

Permalink
Merge pull request #9 from branchvincent/py312
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKing authored Dec 4, 2024
2 parents 05e6353 + 78f9e64 commit b0b5e25
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions textract/parsers/pdf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
from .utils import ShellParser
from .image import Parser as TesseractParser

from distutils.spawn import find_executable
try:
from shutil import which
except ImportError:
from distutils.spawn import find_executable as which

class Parser(ShellParser):
"""Extract text from pdf files using either the ``pdftotext`` method
Expand Down Expand Up @@ -49,7 +52,7 @@ def extract_pdfminer(self, filename, **kwargs):
#Nested try/except loops? Not great
#Try the normal pdf2txt, if that fails try the python3
# pdf2txt, if that fails try the python2 pdf2txt
pdf2txt_path = find_executable('pdf2txt.py')
pdf2txt_path = which("pdf2txt.py")
try:
stdout, _ = self.run(['pdf2txt.py', filename])
except OSError:
Expand Down

0 comments on commit b0b5e25

Please sign in to comment.