Greetings this is my code:
def triagePrintTags(bikeIds):
assert(bikeIds != None)
assert(isinstance(bikeIds, list) or isinstance(bikeIds, tuple))
pdf = FPDF('P', 'mm', (66.548, 25.4))
# get all the r(ows
rows = db(db.bike.id.belongs(bikeIds)).select()
for row in rows:
pdf.add_page()
pdf.set_font('Times', 'B', 8)
idString = row.destination + str(row.id)
pdf.cell(0, 2, idString, 0, 1)
if row.make != None:
pdf.cell(0, 2, "Make: " + row.make,0,1)
if row.model != None:
pdf.cell(0, 2, "Model: " + row.model,0,1)
if row.size != 0:
sz = "Size: " + str(row.size)
pdf.cell(0, 2, sz,0,1)
if row.color != None:
pdf.cell(0, 2, "Color: " + row.color,0,1)
# TODO this should be a true temp file, stored in /tmp with random
unique filename.
fileName = request.folder + '/static/temp.pdf'
pdf.output(name=fileName)
response.headers['Content-Disposition']='attachment.filename =
sample.pdf'
response.headers['Content-Type']='application/pdf'
return response.stream(open(fileName, 'rb'), chunk_size=4096)
the problem with the above code is:
my dimentions of my page are supposed to simulate a label (no problem)
my text should all be on the same label, but when the next cell prints, it
jumps to the
next label. What am I doing incorrectly here?
Or maybe is it is just wrong print with pdf.cell, maybe there is a better
way.
Please help if you can?
Thank you in advance.
--