7

HTMLをPDFに変換するためにxhtml2pdfを使用しています。

何らかの理由で、どの div の幅も検出しません。スタイルを使用して幅を指定しようとしましたが、まだ機能しません。私は何を間違っていますか?

    <html>
<head>

</head>
<body>
<style>
    div{
        width:100pt;
        height:100pt;
        border:Solid red 1pt;
    }
</style>
<div>
    WOw a pdf
</div>
</body>

</html>

上記のコードでは、div の幅が 100px または 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("\\","/")
4

0 に答える 0