Open dikshitkumarmodi opened 2 years ago
I have the same exact issue - what you need to check is for any external references in the html you're passing down to wkhtmltopdf. For me, I was referencing a font file by a relative path, and I guess wkhtmltopdf doesn't know how to traverse the filesystem here or what the base path should be. I think that possibly the best option is to use only url references and be explicit about the protocol - the protocol unknown error being the clue here. So no //
or file://
- try using https://
when referring to external content.
Hi :)
I had the same problem as you. If files such as images/css/fonts are located in the local storage next to the html file, you can use the following example:
import pdfkit
options = {
"enable-local-file-access": "",
}
pdfkit.from_file("input.html", "out.pdf", options=options)
For reference, this is due to an upstream change which was made in wkhtmltopdf 0.12.6: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/4536
pdfkit error: Exit with code 1 due to network error: ProtocolUnknownError
I'm trying to convert an HTML file to PFD with the pdfkit package. Here is my python code:
Code sample
But I'm getting this error:
What is wrong here? What is the solution?
Your environment