Search code examples
pythonhtmlpdfpyinstallerpdfkit

pdfkit is crushing exe from pyinstaller


I have this project in which I convert HTML files I create to PDF. Basically I create two HTML files, merge them into a single HTML file, and I convert this file with pdfkit. When I run my code in Spyder everything is fine, I get this message in the terminal:

Loading pages (1/6)
Counting pages (2/6)                                               
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done   

and I get my desired PDF files, and I can also see the three HTML files (the two I create and the merged one) and also some pictures I save from my GUI and attach to my HTML/PDF files.

So far so good, but when I convert my code with pyinstaller it crushes on the PDF conversation.. I use this line to convert my HTML to PDF:

pdfkit.from_file(fileAddress_final,fileAddress_PDF)

where fileAddress_final is the merged HTML file, and fileAddress_PDF is the desired path to where the PDF file would be saved.

When I tried to run an .exe file without the line above, it did not crush (but obviously does not create the PDF file I wish).

I tried to find an answer to it before, but I might have not been clear enough, and also ran some tests, so I managed to find out that this is the only line that causes problems.

Did anyone experience this kind of thing as well? Any ideas of how to fix it?


Solution

  • I found how I can silence the output, I just simply had to add this:

    options = {
               'quiet': ''
              }
    pdfkit.from_file(fileAddress_final,fileAddress_PDF,options=options)
    

    And this stopped the output, and prevented from my GUI to crash.