I am converting HTML to PDF. PDF downloaded success but it return blank pdf pages not showing any converted content. in my HTML file have Shopify CSS links. if convert minimum content HTML file then it converted correctly
from django.shortcuts import render from django.http import HttpResponse import pdfkit from django.conf import settings
def convert_html_to_pdf(request):
if request.method == 'POST':
rendered_template = render(request, 'newundergrace.html') HTML file
options = {
'enable-local-file-access': '',
'orientation': 'landscape',
'page-size': 'Letter',
'page-size': 'A4',
'margin-top': '0',
'margin-right': '0',
'margin-bottom': '0',
'margin-left': '0',
'dpi': 96,
}
rendered_content = rendered_template.content.decode('utf-8')
pdf = pdfkit.from_string(rendered_content, False, options=options)
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename=output.pdf'
response.write(pdf)
return response
return render(request, 'index1.html')