Python xhtml2pdf未检测到div宽度
我正在使用xhtml2pdf将html转换为pdf 由于某些原因,它没有检测到任何div的宽度。我尝试过使用样式指定宽度,但仍然不起作用。我做错了什么Python xhtml2pdf未检测到div宽度,python,django,xhtml2pdf,Python,Django,Xhtml2pdf,我正在使用xhtml2pdf将html转换为pdf 由于某些原因,它没有检测到任何div的宽度。我尝试过使用样式指定宽度,但仍然不起作用。我做错了什么 <html> <head> </head> <body> <style> div{ width:100pt; height:100pt; border:Solid red 1pt; } </style>
<html>
<head>
</head>
<body>
<style>
div{
width:100pt;
height:100pt;
border:Solid red 1pt;
}
</style>
<div>
WOw a pdf
</div>
</body>
</html>
我遇到了同样的问题;你找到工作了吗?没有。但它检测表列的宽度,我在所有地方都使用了表而不是div。那么高度呢?无法将高度应用于任何图元您可以显式地为每个图元添加高度和宽度。您已将其专门添加到每个元素。您将宽度和高度专门添加到每个元素是什么意思?我怎样才能做到?
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("\\","/")