Hello Alfonso you can not use css with fpdf. It doesn't understand most of it, you have to use html. To change font size, I use, as an example: pdf.write_html('<font size="10">' + tabla.xml().decode('utf-8') + '</font>')
where tabla is a html table I've previously built using web2py html helpers (TR, TH,TBODY,TD,TABLE,THEAD , etc.) Hope this helps. Regards. 2013/12/20 Alfonso Pastor Sierra <alfonso.pas...@gmail.com>: > Hi, I have the code for a PDF Report: > > def export_pdf(): > > title = "Informe de impresiones" > > head = THEAD(TR(TH("Fecha/Hora",_width="16%"), > TH("Impresora",_width="17%"), > TH("Host",_width="10%"), > TH("Usuario",_width="10%"), > TH("Trabajo",_width="33%"), > TH("Pag",_width="4%"), > TH("Cop",_width="4%"), > TH("Total",_width="6%"), > _bgcolor="#A0A0A0")) > > > rowsTable = [] > i=0; > > rows=consultaInforme() > > for r in rows: > > col = i % 2 and "#F0F0F0" or "#FFFFFF" > > documento=r[6].encode("latin_1","replace")[:50] > > rowsTable.append(TR(TD(r[1], _align="left"), > TD(r[2], _align="left"), > TD(r[5], _align="left"), > TD(r[4], _align="left"), > TD(documento, _align="left"), > TD(r[7], _align="center"), > TD(r[8], _align="center"), > TD(r[9], _align="center"), > _bgcolor=col)) > > i+=1 > > body = TBODY(*rowsTable) > table = TABLE(*[head, body], _border="1", _align="center", > _width="100%") > > class MyFPDF(FPDF, HTMLMixin): > > def __init__(self): > FPDF.__init__(self,'L') > > def header(self): > self.set_font('Arial','B',15) > self.cell(0,10, title ,1,0,'C') > > def footer(self): > self.set_y(-15) > self.set_font('Arial','I',8) > self.cell(0,10,"IES",0,0,'L') > txt = 'Pag. %s de %s' % (self.page_no(), self.alias_nb_pages()) > self.cell(0,10,txt,0,0,'R') > > pdf=MyFPDF() > pdf.add_page() > > pdf.write_html(str(XML(table, sanitize=False))) > > response.headers['Content-Type']='application/pdf; charset=utf-8' > doc=pdf.output(dest='S') > doc64=embed64(data=doc,extension='application/pdf') > return 'window.open("%s");' % doc64 > > def consultaInforme(): > > ....blah..blah.blah.... > ............................. > > > consulta=cdb.executesql(sql) > > return consulta > > > And I want to change the font-size of the text inside the table, but I > can't. > I have tried without success: > > > rowsTable.append(TR(TD(r[1], _align="left"), > TD(r[2], _align="left"), > TD(r[5], _align="left"), > TD(r[4], _align="left"), > TD(documento, _align="left"), > TD(r[7], _align="center"), > TD(r[8], _align="center"), > TD(r[9], _align="center"), > _bgcolor=col, _style="font-size: 8px;")) > > > > and > > pdf=MyFPDF() > pdf.add_page() > pdf.set_font('Arial','',10) > pdf.write_html(str(XML(table, sanitize=False))) > > > > But never changes the font size in pdf. > > Can you help me? > > > > > > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.