I am using pdfkit to convert html into pdf. Everything seems to be working perfectly in development, but after building a docker image and running it locally, the pdf is generated but images are not loaded.
Here is my how I am rendering image, which seems to be working fine locally:
<img src="{{ host_url }}/static/tcs.jpg" style="width:100px;display:block;" />
Here's my code in django view function:
template = get_template("tcs_invoice.html")
data = {
"host_url": settings.HOST
}
html = template.render(data) # Renders the template with the context data.
pdf = pdfkit.from_string(html, False)
return HttpResponse(pdf, content_type='application/pdf')
I have installed wkhtmltopdf on my docker container. When I hit the url in the browser the image is shown. why does it not render in production mode.