I am using xhtml2pdf for converting html to pdf.
For some reason it does not detect the width of any div. I have tried giving width using style it still does not work. What am I do doing wrong?
<html>
<head>
</head>
<body>
<style>
div{
width:100pt;
height:100pt;
border:Solid red 1pt;
}
</style>
<div>
WOw a pdf
</div>
</body>
</html>
In the above code the div does not have a width of 100px or 100pt.
def myview(request):
options1 = ReportPropertyOption.objects.all()
for option in options1:
option.exterior_images = ReportExteriorImages.objects.filter(report = option)
option.interior_images = ReportInteriorImages.objects.filter(report = option)
option.floorplan_images = ReportFloorPlanImages.objects.filter(report = option)
html = render_to_string('report/export.html', { 'pagesize' : 'A4', }, context_instance=RequestContext(request,{'options1':options1}))
result = StringIO.StringIO()
pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")), dest=result, link_callback=fetch_resources )
if not pdf.err:
return HttpResponse(result.getvalue(), mimetype='application/pdf')
return HttpResponse('Gremlins ate your pdf! %s' % cgi.escape(html))
def fetch_resources(uri, rel):
path = os.path.join(settings.MEDIA_ROOT, uri.replace("/media/", ""))
return path.replace("\\","/")