diff --git a/oml/media/pdf.py b/oml/media/pdf.py index 5238685..b370525 100644 --- a/oml/media/pdf.py +++ b/oml/media/pdf.py @@ -229,18 +229,19 @@ def info(pdf): ''' def extract_text(pdf): + if sys.platform == 'win32': + pdf = get_short_path_name(pdf) if sys.platform == 'darwin': cmd = ['/usr/bin/mdimport', '-d2', pdf] else: - if sys.platform == 'win32': - pdf = get_short_path_name(pdf) cmd = ['pdftotext', pdf, '-'] if sys.platform == 'win32': startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = subprocess.SW_HIDE p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo) - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + else: + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() stdout = stdout.decode() stderr = stderr.decode()