简体   繁体   English

wkhtmltopdf - 由于网络错误而退出代码 1:ContentNotFoundError

[英]wkhtmltopdf - Exit with code 1 due to network error: ContentNotFoundError

I am trying to build a PDF file out of the HTML file.我正在尝试从 HTML 文件中构建一个 PDF 文件。 When I run the command to convert the HTML file the response was当我运行命令转换 HTML 文件时,响应是

Counting pages (2/6)                                               
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done                                                                      
Exit with code 1 due to network error: ContentNotFoundError

This is happening when the renderer could not load a/some javascript/image/font file.当渲染器无法加载/某些 javascript/image/font 文件时,就会发生这种情况。 After resolving missing resource, the issue was fixed.解决丢失资源后,问题得到解决。

SOLUTION: This is for those with the error:解决方案:这是针对那些有错误的人:

Exit with code 1 due to network error: ProtocolUnknownError由于网络错误,以代码 1 退出:ProtocolUnknownError

If you get an error when uploading an image/media, you have to upload that image to your own http server or hosting, for example in XAMPP.如果上传图像/媒体时出错,则必须将该图像上传到您自己的 http 服务器或主机,例如在 XAMPP 中。 Put the complete link of the image in the html, example:把图片的完整链接放在html中,例如:

<img src='https://127.0.0.1/web/chart.jpg'>

In this way the images will be loaded well at the time of passing them to pdf.这样,图像将在将它们传递到 pdf 时很好地加载。 When creating the pdf, you can already delete the image from the hosting or remove the server.创建 pdf 时,您已经可以从托管中删除图像或删除服务器。

I had similar experience and had encountered with the same error (Also I have put complete code in My GitHub ).我有类似的经历并且遇到了同样的错误(我也在我的 GitHub中放入了完整的代码)。 But my code was like this:但我的代码是这样的:

import pdfkit
pdfkit.from_url("https://www.google.com", "google.pdf" , configuration = config)

I changed HTTPS to HTTP and it fixed the error.我将HTTPS更改为HTTP并修复了错误。 like this:像这样:

import pdfkit
pdfkit.from_url("http://www.google.com", "google.pdf" , configuration = config)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决 python pdfkit 中的“wkhtmltopdf 报告错误:由于网络错误退出代码 1:ProtocolUnknownError” - How to solve "wkhtmltopdf reported an error: Exit with code 1 due to network error: ProtocolUnknownError" in python pdfkit pdfkit 错误:由于网络错误,退出代码 1:ProtocolUnknownError - pdfkit error: Exit with code 1 due to network error: ProtocolUnknownError 带有django的pdfkit由于网络错误而给出错误退出,代码为1:ContentOperationNotPermittedError - pdfkit with django gives error Exit with code 1 due to network error: ContentOperationNotPermittedError Python GIT 结帐失败,原因是:退出代码(1) - Python GIT CHeckout failed due to: exit code(1) `pip install flask_mysqldb`由于clang失败:错误:链接器命令失败,退出代码为1 - `pip install flask_mysqldb` fails due to clang: error: linker command failed with exit code 1 NLTK和MaltParser退出,错误代码为1 - NLTK and MaltParser exit with error code 1 wkhtmltopdf 以非零代码 -9 退出。 错误。 我怎样才能摆脱这个错误? - wkhtmltopdf exited with non-zero code -9. error. How can I get rid of this error? “ Read_Ncol”出口,错误代码-1073740791 - “Read_Ncol” exit with error code -1073740791 Locust 不支持 `--exit-code-on-error` 参数? - Locust not supporting `--exit-code-on-error` argument? 根据先前的错误代码退出csh脚本 - Exit csh script based on previous error code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM