templated-docs icon indicating copy to clipboard operation
templated-docs copied to clipboard

image not displayed correctly in pdf

Open giuseppecristofaro opened this issue 8 years ago • 0 comments

  • Templated-docs version: 0.3.1
  • Python version: 2.7.13
  • Operating System: Debian 9.0

Description

When I generate the pdf with images, in the generated PDF only a white image with a border instead of the original image appears

What I Did

VIEWS.PY context = {} attach = Attachment() soup = BeautifulSoup(description) descriptions = soup.findAll('p') for d in descriptions: token = str(d)[3:-4] if token[:9] == '<img src=': format, imgstr = token.split(';base64,') ext = format.split('/')[-1] data = ContentFile(base64.b64decode(imgstr), name='temp.' + ext) attach.attach = data attach.save() dd.append(attach.attach) context['dd'] = dd filename = fill_template('invoice/invoice2.odt', context, output_format='pdf') visible_filename = 'invoice.{}'.format('pdf') return FileResponse(filename, visible_filename)

INVOICE2.ODT {% load templated_docs_tags %} {% for d in dd %} {% image d %} {% endfor %}

giuseppecristofaro avatar Nov 27 '17 11:11 giuseppecristofaro