EpubToPDF项目复现记录

项目地址:https://github.com/HAKSOAT/EpubToPdf

报错记录:按照readme中安装好依赖库后,运行后报错。

错误1:

1
'gbk' codec can't decode byte 0xa2 in position 153: illegal multibyte sequence

“GBK”,一眼编码问题,根据报错提示找到代码中open()函数的位置,设置encoding参数即可。

修改完后重新运行代码,报错。

错误2:

1
2
No wkhtmltopdf executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

原因是未找到wkhtmltopdf这个程序,从官网下载安装,配置环境变量,重新运行,仍然报错,从网上查下解决办法,手动在代码中添加安装路径。

1
2
path_wk = r'F:\Application Installation Files\wkhtmltopdf\bin\wkhtmltopdf.exe' #安装位置
config = pdfkit.configuration(wkhtmltopdf = path_wk)

在pdfpy.py文件的PdfEngine类中首行添加,因为main.py只import了这一个类,在类外边会无效。

修改完后,重新运行代码,成功运行,如下:

1
2
3
4
5
6
(gxb) F:\Project Files\EpubToPdf-master>python main.py x86汇编语言_从实模式到保护模式.epub
--- Sections converted to pdf
--- Epub to PDF conversion started
--- Sections combined together in a single pdf file
--- Individual pdf files deleted from directory
--- Epub to PDF conversion successful