I've just checked pdflabel is not included in fpdf in web2py. I ignore the reason because I uploaded it to pyfpdf 18 months ago. I thought web2py automatically included pyfpdf updates. You can download it from http://code.google.com/p/pyfpdf/source/browse/pdflabels.py and copy it at gluon/contrib/fpdf directory so you can use:
from gluon.contrib.fpdf.pdflabels import PDFLabel PDFLabel accepts "\n" , if you use cell, it doesn't understand "\n" Regards. 2013/1/16 Paul Rykiel <[email protected]>: > Hi Jose, > > I tried what you suggested, I was getting errors on the line > from glon.contrib.pyfpdf.pdflabels import PDFLabel ... it does not seem to > exist, and cannot find how to load this > > so, my other option seems to be to get all of the text inside of one cell, > so I used your "more_text" from below, it works ('sort of") ... it lists all > of the text inside the one cell, but > the program is ignoring the "\n" page breaks, if I can get those to work, I > am almost done > > then I have to figure out how to create the pages side by side, but I want > to tackle one thing at a time. > > I am sure when I get to my next issue of printing the labels where there are > 3 labels across and 10 down, maybe I will have to figure out > how to use the PDFLabel, but for right now I just want to get this to work. > > thanks for all of your help!! > Regards, > > > On Wednesday, January 16, 2013 12:46:34 PM UTC-6, José L. wrote: >> >> Some time ago, we include PDFLabel too, so you can simplify your code >> if you are using an avery-compatible format ( the sys stuff is only >> needed if you're using a non-english language): >> >> def label_bikes(): >> from gluon.contrib.pyfpdf.pdflabels import PDFLabel >> import sys >> reload(sys) >> sys.setdefaultencoding( "latin-1" ) >> >> pdf = PDFLabel('Apli-01277') >> pdf.add_page() >> rows = db(db.bike.id.belongs(bikeIds)).select() >> # Print labels >> for row in rows: >> idString = row.destination + str(row.id) >> more_text = idString >> more_text += "Make: " + row.make + "\n" if row.make else "" >> more_text += "Model: " + row.model + "\n" if row.model else "" >> more_text += "Size: " + row.size + "\n" if row.size else "" >> pdf.add_label(more_text) >> >> response.headers['Content-Type'] = 'application/pdf' >> response.headers['Content-Disposition']='attachment.filename = >> sample.pdf' >> return pdf.output(dest='S') >> >> >> Regards >> José L. >> >> 2013/1/16 Paul Rykiel <[email protected]>: >> > Hi Mariano, >> > thank you for the response. Let me look into the margin issue, maybe you >> > have given me enough to figure this out. >> > thanks so much for the response. you know, Massimo was my professor last >> > term. >> > >> > On Wednesday, January 16, 2013 12:39:06 AM UTC-6, Mariano Reingart >> > wrote: >> >> >> >> Hello Paul: >> >> >> >> Could you send a sample without actual data? >> >> (without the db query, so it can be reproduced) >> >> >> >> fpdf.cell will jump to the next page if no more room available, maybe >> >> there is a sizing or rounding issue. >> >> Also, you have to take a look at page margins. >> >> >> >> Best regards, >> >> >> >> Mariano Reingart >> >> http://www.sistemasagiles.com.ar >> >> http://reingart.blogspot.com >> >> >> >> >> >> On Tue, Jan 15, 2013 at 8:02 PM, Paul Rykiel <[email protected]> wrote: >> >> > 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. >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > -- >> >> > >> >> > >> >> > >> > >> > -- >> > >> > >> > > > -- > > > --

