1

I'm using following code to parse a pdf in Spyder IDE:

from pdfminer3.layout import LAParams, LTTextBox
from pdfminer3.pdfpage import PDFPage
from pdfminer3.pdfinterp import PDFResourceManager
from pdfminer3.pdfinterp import PDFPageInterpreter
from pdfminer3.converter import PDFPageAggregator
from pdfminer3.converter import TextConverter
import io

resource_manager = PDFResourceManager()
fake_file_handle = io.StringIO()
converter = TextConverter(resource_manager, fake_file_handle, laparams=LAParams())
page_interpreter = PDFPageInterpreter(resource_manager, converter)

with open('C:/Test/file.pdf', 'rb') as fh:

    for page in PDFPage.get_pages(fh,
                                  caching=True,
                                  check_extractable=True):
        page_interpreter.process_page(page)

    text = fake_file_handle.getvalue()

# close open handles
converter.close()
fake_file_handle.close()

print(text)

Source: https://stackoverflow.com/a/56530666/803687

But I'm not getting any output in the IPython Console within Spyder IDE.

Python version: 3.7.4
Spyder version: 3.3.6
OS: Windows 10

The console simply goes blank:

Python 
Type "copyright", "credits" or "license" for more information.

IPython  -- An enhanced Interactive Python.

In [1]: runfile('C:/Temp//PdfParser.py', wdir='C:/Temp/')

In [2]: 

Same code when I execute as py file from Annaconda console, it shows the output.

Any setting is there which will show the output on console? Normally it shows the output when I just print Hello-World.

Anand
  • 2,239
  • 4
  • 32
  • 48

0 Answers0