Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

python 3.x - Pdfminer, can not read LTText after pyinstaller

I make an app that can read PDF using pdfminer.
enter image description here
Application is OK when development.
After that, I package to .exe file using pyinstaller. But read result is not the same with it in development.
In detail, it can not read **LTText LTTextBoxHorizontal so I can not get extracted text.
Any one know about this issue, please help me.


Logs in development Logs in development

Logs after I do pyinstaller

Logs after I do pyinstaller

Python 3.9.1
Pyinstaller 4.2
pdfminer.six==20201018
six==1.15.0
Command: pyinstaller --onefile file.py

Related source:

 for index, page in pdf_object:
            # TODO: Only read last page - maybe change if PDF file change
            if index == number_of_page - 1:
                # read the page into a layout object
                self.interpreter.process_page(page)
                layout = self.device.get_result()
                print("Size of this page (%d, %d)" % (layout.x1, layout.y1))
                print("len = %d" % len(layout._objs))
                self.parse_obj(layout._objs)


def parse_obj(self, lt_objs):
    # loop over the object list
    print("Go loop")
    print(lt_objs)
    i = 0
    for obj in lt_objs:
        i += 1
        print("In loop %d" % i)
question from:https://stackoverflow.com/questions/65843216/pdfminer-can-not-read-lttext-after-pyinstaller

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Pyinstaller lib owner just answered me. It fixed by adding --additional-hooks-dir.

Please see here for detail.

Maybe they will fix in pyinstaller to support pdfminer also in next release.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...