why PyPDF2 is working only outside pyQt5?

0

I designed a GUI interface using Pyqt5 and want to read a PDF file sadly without any luck. The code works flawlessly outside the GUI code but once it is linked to the "open file function" it doesn't work.

#this is the code that works perfectly outside GUI

import PyPDF2
pdfFileObject = open("thefilename.pdf", "rb")
pdfReader = PyPDF2.PdfFileReader(pdfFileObject)
count = pdfReader.numPages
for i in range(count):
    page = pdfReader.getPage(i)
    s = page.extractText()
    print(s)

#this is the function I use to open files in Pyqt5 code:

def opening_files(self):
    filename = QFileDialog.getOpenFileName()
    g = open(filename[0])

I tried everything, tried to open the file as: open("filename.pdf"), "rb") but doesn't work either.

I am always receiving this error:

Process finished with exit code -1073740791 (0xC0000409)
python
user-interface
pyqt5
asked on Stack Overflow Jun 22, 2020 by Kamarbasha • edited Jun 23, 2020 by Daniel Walker

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0