jeudi 2 août 2018

Python & Django : Creating Checkboxes and letterboxes with reportlab

I'm new to reportlab library , and I've been creating pdfs using reportlab, the pdf I need to create now contains checkboxes and letterboxes , but I cant find how to do so. here is an exemple of how I create pdf on my view.py:

buff = BytesIO()
                menu_pdf = SimpleDocTemplate(buff, rightMargin=60,
                                            leftMargin=60, topMargin=40, bottomMargin=65)
                response = HttpResponse(content_type='application/pdf')

cachet="<para alignment='right'>Cachet et signature :</para>"
                t=[]
                t.append(Paragraph(cachet,stylex1))
                tit=[[t]]
                Table_t=Table(tit,colWidths=(180*mm))
                Table_t.setStyle(TableStyle([('BOX', (0,0), (-1,-1), 0.25, colors.black), ('BACKGROUND', (-2, 0), (-2, -1), colors.white), ('INNERGRID', (0,0), (-1,-1), 0.5, colors.black)]))
                story.append(Table_t)
menu_pdf.build(story)
    response.write(buff.getvalue())
    buff.close()

when I search how to create checkboxes I only find the canvas way . however letterboxes are only available on RML My question is : is there a way to create checkboxes and letterboxes with the build(story) way . because I dont want to save pdf to disk I need to generate them automatically and let the user choose to save or not save it.

Any help please ? THANK YOU In Advance




Aucun commentaire:

Enregistrer un commentaire