Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image not displayed correctly in pdf #21

Open
giuseppecristofaro opened this issue Nov 27, 2017 · 0 comments
Open

image not displayed correctly in pdf #21

giuseppecristofaro opened this issue Nov 27, 2017 · 0 comments

Comments

@giuseppecristofaro
Copy link

  • 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 %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant