| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
代码 
# encoding=utf-8 
import pdfkit 
config = pdfkit.configuration(wkhtmltopdf = r"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe") 
pdfkit.from_url(url, r'D:\1.pdf', configuration=config,options={'encoding':'utf-8',"enable-local-file-access":True}) 
 
 
 
错误代码 
Traceback (most recent call last): 
  File "D:\parcharm\cs1.py", line 4, in <module> 
    pdfkit.from_url(url, r'D:\1.pdf', configuration=config,options={'encoding':'utf-8',"enable-local-file-access":True}) 
  File "D:\parcharm\venv\lib\site-packages\pdfkit\api.py", line 27, in from_url 
    return r.to_pdf(output_path) 
  File "D:\parcharm\venv\lib\site-packages\pdfkit\pdfkit.py", line 201, in to_pdf 
    self.handle_error(exit_code, stderr) 
  File "D:\parcharm\venv\lib\site-packages\pdfkit\pdfkit.py", line 155, in handle_error 
    raise IOError('wkhtmltopdf reported an error:\n' + stderr) 
OSError: wkhtmltopdf reported an error: 
content-type missing in HTTP POST, defaulting to application/x-www-form-urlencoded. Use QNetworkRequest::setHeader() to fix this problem. 
libpng warning: iCCP: known incorrect sRGB profile 
libpng warning: iCCP: known incorrect sRGB profile 
Exit with code 1 due to network error: ContentNotFoundError 
 
 
Process finished with exit code 1 
 |   
 
 
 
 |