convert html to pdf
Budget: ₹100 – ₹400 INR
i need this html page converted into pdf using django and python
https://harnishdesign.net/demo/html/koice/index-2.html
==========
existing django code
===
path_to_wkhtmltopdf = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_to_wkhtmltopdf)
static_dir = os.path.join(settings.BASE_DIR, 'assets')
css_path = os.path.join(static_dir, 'css', 'bootstrap.min.css')
if not os.path.exists(css_path):
print("error not found")
context = {
'invoice_id': invoice_id,
'css_path': css_path,
'invoice_id': invoice_id
}
options = {
'enable-local-file-access': None
}
html_content = render_to_string('invoice-template-1.html', context)
pdf_document = pdfkit.from_string(html_content, False, configuration=config, options=options)
response = HttpResponse(pdf_document, content_type='application/pdf')
response['Content-Disposition'] = f'attachment; filename="invoice_{invoice_id}.pdf"'
return response
https://harnishdesign.net/demo/html/koice/index-2.html
==========
existing django code
===
path_to_wkhtmltopdf = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'
config = pdfkit.configuration(wkhtmltopdf=path_to_wkhtmltopdf)
static_dir = os.path.join(settings.BASE_DIR, 'assets')
css_path = os.path.join(static_dir, 'css', 'bootstrap.min.css')
if not os.path.exists(css_path):
print("error not found")
context = {
'invoice_id': invoice_id,
'css_path': css_path,
'invoice_id': invoice_id
}
options = {
'enable-local-file-access': None
}
html_content = render_to_string('invoice-template-1.html', context)
pdf_document = pdfkit.from_string(html_content, False, configuration=config, options=options)
response = HttpResponse(pdf_document, content_type='application/pdf')
response['Content-Disposition'] = f'attachment; filename="invoice_{invoice_id}.pdf"'
return response