wks icon indicating copy to clipboard operation
wks copied to clipboard

应该也是字体的原因吧?

Open 602383883 opened this issue 2 years ago • 1 comments

C:\Users\123\Desktop\wks-main>python main.py -C cookie.txt -o 1.pdf "https://wenku.baidu.com/view/8dc157a94b35eefdc8d33398.html" Download from https://wenku.baidu.com/view/8dc157a94b35eefdc8d33398.html Download HTML...Success. Parse HTML...Success. title: 霍尼韦尔DCS操作手册(通用) Found pdf file, prepare for download...Success. page: 1-45 Start downloading font(s)... |=================================================>| 45 / 45 (100.00%) Start downloading json(s)... |=================================================>| 45 / 45 (100.00%) Start downloading png(s)... |=================================================>| 45 / 45 (100.00%) Start generating pdf... Font "SimSun" missing, will be repalce by "SimSun Bold" (c8081622ed630b1c59eeb5f70010001.ttf) Font "SimSun Bold" missing, will be repalce by "SimSun Bold" (c8081622ed630b1c59eeb5f70010001.ttf) |>-------------------------------------------------| 1 / 45 (2.22%)Traceback (most recent call last): File "C:\Users\123\AppData\Local\Programs\Python\Python310\lib\site-packages\reportlab\pdfbase\pdfmetrics.py", line 697, in getFont return _fonts[fontName] KeyError: 'c8081622ed630b1c59eeb5f70010001'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\123\Desktop\wks-main\main.py", line 260, in font_replace = save_pdf(temp_dir, pagenums[i], font_replace=font_replace) File "C:\Users\123\Desktop\wks-main\json2pdf.py", line 91, in save_pdf textobject.setFont( File "C:\Users\123\AppData\Local\Programs\Python\Python310\lib\site-packages\reportlab\pdfgen\textobject.py", line 318, in setFont font = pdfmetrics.getFont(self._fontname) File "C:\Users\123\AppData\Local\Programs\Python\Python310\lib\site-packages\reportlab\pdfbase\pdfmetrics.py", line 699, in getFont return findFontAndRegister(fontName) File "C:\Users\123\AppData\Local\Programs\Python\Python310\lib\site-packages\reportlab\pdfbase\pdfmetrics.py", line 681, in findFontAndRegister face = getTypeFace(fontName) File "C:\Users\123\AppData\Local\Programs\Python\Python310\lib\site-packages\reportlab\pdfbase\pdfmetrics.py", line 638, in getTypeFace return _typefaces[faceName] KeyError: 'c8081622ed630b1c59eeb5f70010001'


还有https://wenku.baidu.com/view/460a831ab7360b4c2f3f6401 可以正常运行下载完,但是很多中文直接没显示出来

602383883 avatar Jul 24 '22 17:07 602383883

已复现问题。百度文库为了节省流量把字体文件拆分成每页用到的字体,导致合成时出现问题。我尝试是否可以使用本地字体替换其提供的字体。

BoyInTheSun avatar Jul 25 '22 01:07 BoyInTheSun