Skip to content

Instantly share code, notes, and snippets.

@olivx
Created March 28, 2018 01:33
Show Gist options
  • Save olivx/bc2e34a2e1633ff7af3fdd58792e4bb1 to your computer and use it in GitHub Desktop.
Save olivx/bc2e34a2e1633ff7af3fdd58792e4bb1 to your computer and use it in GitHub Desktop.
# weasyprint
from weasyprint import HTML
context = {}
html_string = render_to_string('template.html', context=context, request=request)
html = HTML(string=html_string)
file_name = '%s.pdf' % obj.pk
pdf_path = os.path.join(settings.MEDIA_ROOT, 'resumes', file_name)
html.write_pdf(target=pdf_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment