Following is my code but i don't get the report in proper format and when we got the pdf than the column is collapse with each other so please kindly help me :-
def listing(): response.title = "abc" # define header and footers: head = THEAD(TR(TH("Activity",_width="20%"), TH("Due Date",_width="10%"), TH("Company",_width="10%"), TH("city",_width="10%"), TH("Area of Law",_width="10%"), TH("legislation",_width="10%"), TH("Rules and Regulations",_width="20%"), TH("Status",_width="10%"), _bgcolor="#A0A0A0")) foot = TFOOT(TR(TH("LCM+",_width="100%", _align="center"), _bgcolor="#E0E0E0")) # create several rows: rows = [] for row in db((db.compliance_tracker.company == session.company) & (db.compliance_tracker.time_line >= session.strtdate) & (db.compliance_tracker.time_line <= session.enddate)).select(): col = row.id % 2 and "#F0F0F0" or "#FFFFFF" rows.append(TR(TD('%s'%row.compliance_activity,_width="20%"), TD("%s"%row.time_line,_width="10%"), TD("%s"%row.company,_width="10%"), TD("%s"%row.city,_width="10%"), TD("%s"%row.area_of_law,_width="10%"), TD("%s"%row.legislation,_width="10%"), TD("%s"%row.rules_and_regulations,_width="20%"), TD("%s"%row.status,_width="10%"), _bgcolor=col)) # make the table object body = TBODY(*rows) table = TABLE(*[head,foot, body], _border="1", _align="center", _width="100%") if request.extension=="pdf": from gluon.contrib.pyfpdf import FPDF, HTMLMixin # define our FPDF class (move to modules if it is reused frequently) class MyFPDF(FPDF, HTMLMixin): def header(self): self.set_font('Arial','B',12) self.cell(0,10, response.title ,1,0,'C') self.ln(20) def footer(self): self.set_y(-15) self.set_font('Arial','I',8) txt = 'Page %s of %s' % (self.page_no(), self.alias_nb_pages()) self.cell(0,10,txt,0,0,'C') pdf=MyFPDF() # first page: pdf.add_page() pdf.write_html(str(XML(table, sanitize=False))) response.headers['Content-Type']='application/pdf' return pdf.output(dest='S') else: # normal html view: return dict(table=table)