'how to add second page reportlab in django
my goal is to write the data in the models to a pdf file so that if it doesn't fit on the first page, it will automatically continue on to the second page. is writing me a page again and again on a sheet of code pls help me
from django.shortcuts import render
from django.http import HttpResponse,HttpResponseRedirect
# Create your views here.
from .forms import VenueForm
from .models import *
from django.http import FileResponse
import io
from reportlab.platypus import PageBreak
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import inch
from reportlab.lib.pagesizes import letter
def venue_pdf(request):
buf = io.BytesIO()
c = canvas.Canvas(buf,pagesize=letter,bottomup=0)
textob=c.beginText()
textob.setTextOrigin(inch,inch)
textob.setFont("Helvetica",14)
venues = Venue.objects.all()
l = []
for i in venues:
l.append(i.lname)
l.append(i.fname)
l.append(i.fan)
l.append(i.address)
l.append(i.phone)
l.append(" ===================================================== ")
l.append(" ")
for j in range(len(l)//36+1):
c.drawText(textob)
c.showPage()
c.save()
buf.seek(0)
return FileResponse(buf,as_attachment=True,filename='east_ariza.pdf')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
