File size: 585 Bytes
197a58a
 
 
 
4540635
 
 
197a58a
 
 
 
97ddf52
197a58a
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from reportlab.lib.pagesizes import A5
from reportlab.pdfgen import canvas

def create_receipt(text, file_name):
    text=text.rplace('*','')
    text=text.replace('#','')
    text=text.replace('Reçu','')
    pdf = canvas.Canvas(file_name, pagesize=A5)
    width, height = A5

    pdf.setFont("Helvetica-Bold", 16)
    pdf.drawCentredString(width / 2, height - 50, "Reçu")

    pdf.setFont("Helvetica", 12)
    text_object = pdf.beginText(50, height - 100)

    for line in text.split("\n"):
        text_object.textLine(line.strip())

    pdf.drawText(text_object)

    pdf.save()