J
J
Junior932017-04-27 07:20:12
Django
Junior93, 2017-04-27 07:20:12

How to insert image into pdf WeasyPrint?

Good afternoon.
Maybe someone has already encountered a problem, not how it is impossible to insert an image into a pdf.
my generate function

def get_pdf(self, request):
    rendered_html = html_pdf('test.html')
    pdf = HTML(string=rendered_html, base_url=request.build_absolute_uri()).write_pdf()
    return pdf

in html i insert image like this
{% load static %}
<img src="{% static '1.png' %}"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Great274, 2017-05-05
@Great274

from django.template import Context
from django.template.loader import get_template
template = get_template(template_src)
context = Context(context_dict)
html = template.render(context)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question