<commit_before>from io import BytesIO
from reportlab.pdfgen import canvas
from django.http import HttpResponse, HttpRequest

def exportOrderToPDF(request: HttpRequest):
    # Setup the canvas
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'
    buffer = BytesIO()
    p : canvas = canvas.Canvas(buffer)
    # Render PDF
    #Close the canvas
    p.showPage()
    p.save()
    pdf = buffer.getvalue()
    buffer.close()
    response.write(pdf)
    return response
<commit_msg>Getting started with pdf rendering<commit_after>from io import BytesIO
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from django.http import HttpResponse, HttpRequest
from ..models import GroupReservation

def exportOrderToPDF(request: HttpRequest, reservations):
    # Setup the canvas
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'
    buffer = BytesIO()
    p : canvas = canvas.Canvas(buffer, pagesize=A4, pageCompression=0)
    # Render PDF
    w, h = A4
    for reservation in reservations:
        r: GroupReservation = reservation # Just for the sake of having a shourtcut
        p.setFont("Helvetica", 14)
        p.rotate(180)
        p.drawString(10, 10, "Reservation by: " + str(r.createdByUser.displayName))
        p.line(0, 15, w, 15)
        # TODO generate finished link QR code
        text = p.beginText(15, 30)
        text.textLines(r.notes)
        p.drawText(text)
        p.showPage() # End page here (one per request)
    #Close the canvas
    p.showPage()
    p.save()
    pdf = buffer.getvalue()
    buffer.close()
    response.write(pdf)
    return response

{'fraction_non_alphanumeric': 0.0992108229988726, 'fraction_numerical': 0.012401352874859075, 'mean_word_length': 3.404466501240695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2999632', 'n_tokens_mistral': 538, 'n_tokens_neox': 517, 'n_words': 147}