Muneer Muhammed
Muneer Muhammed

Reputation: 953

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

I am trying to build a PDF file out of the HTML file. When I run the command to convert the HTML file the response was

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

Upvotes: 7

Views: 24834

Answers (3)

Farshad Aghasharif
Farshad Aghasharif

Reputation: 49

I had similar experience and had encountered with the same error (Also I have put complete code in My 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. like this :

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

Upvotes: 2

Javier Sossa
Javier Sossa

Reputation: 81

SOLUTION: This is for those with the error:

Exit with code 1 due to network error: 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. Put the complete link of the image in the html, example:

<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. When creating the pdf, you can already delete the image from the hosting or remove the server.

Upvotes: 8

Muneer Muhammed
Muneer Muhammed

Reputation: 953

This is happening when the renderer could not load a/some javascript/image/font file. After resolving missing resource, the issue was fixed.

Upvotes: 4

Related Questions