[英]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.