Answers for "Weasyprint save pdf"

0

Weasyprint save pdf

def generate(student_id):
    student = get_object_or_404(Student, application_id=student_id)
    html = render_to_string('contract.html', {'student': student})
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'filename="some_file.pdf"'
    weasyprint.HTML(string=html).write_pdf('myfile.pdf', 
                                           presentational_hints=True,
                                           stylesheets=[weasyprint.CSS(settings.STATIC_ROOT + '/css/styles.css')])
    return response
Posted by: Guest on May-04-2021

Browse Popular Code Answers by Language