There are still problems...it does not render headers and tables...
On May 26, 11:06 pm, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote: > I just made a change to trunk about. the new generic.pdf uses pyfpdf > and it is smart in locating files for including images. > > massimo > > On May 26, 10:44 pm, Christopher Steel <chris.st...@gmail.com> wrote: > > > > > > > > > I think report.pdf required reportlab? Massimo had an application for > > creating forms that used markmin and latex. > > > This web2py app includes a plugin that implements an assortment of pdf > > stuff (mostly your implementation of pyfpdf and the report.pdf, was > > that a Google thing?. > > > Anyway the plugin is handy for testing and experimenting and includes > > some other PDF examples, one with a different font. > > >http://code.google.com/p/uc-pyfpdf/ > > > If you need some testing let me know, I love PDF's > > > Cheers, > > > Chris > > > On May 26, 3:48 pm, Mariano Reingart <reing...@gmail.com> wrote: > > > > Putting the following code in generic.pdf and getting report.pdf does not > > > work? > > > (also, per default there is a generic.pdf made by massimo that uses > > > markmin and latex if I remember it correctly) > > > > from gluon.contrib.pyfpdf import FPDF, HTMLMixin > > > from gluon.sanitizer import sanitize > > > > class MyFPDF(FPDF, HTMLMixin): > > > pass > > > > pdf=MyFPDF() > > > pdf.add_page() > > > html=response.render('%s/%s.html' % > > > (request.controller,request.function)) > > > html = sanitize(html, escape=False) > > > pdf.write_html(html) > > > response.headers['Content-Type']='application/pdf' > > > response.write(pdf.output(dest='S'), escape=False) > > > > Mariano > > > Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.comOnThu, > > > May 26, 2011 at 4:30 PM, luifran <lbernalhernan...@yahoo.es> wrote: > > > > if I have a view , for example report.html, how I render this view in > > > > pdf with the generic pdf? > > > > > On 4 oct 2010, 17:08, Mariano Reingart <reing...@gmail.com> wrote: > > > >> On Sun, Oct 3, 2010 at 1:10 AM, mdipierro <mdipie...@cs.depaul.edu> > > > >> wrote: > > > > >> > I am sure this can also be done and better with pyfpdf but I have not > > > >> > tried. Perhaps Mariano can help us > > > > >> Having latest web2py versions (including pyfpdf), write in a > > > >> views/generic.pdf: > > > > >> ---- begin file ---- > > > >> {{ > > > > >> from gluon.contrib.pyfpdf import FPDF, HTMLMixin > > > >> from gluon.sanitizer import sanitize > > > > >> class MyFPDF(FPDF, HTMLMixin): > > > >> pass > > > > >> pdf=MyFPDF()pdf.add_page() > > > >> html=response.render('%s/%s.html' % > > > >> (request.controller,request.function)) > > > >> html = sanitize(html, escape=False)pdf.write_html(html) > > > >> response.headers['Content-Type']='application/pdf' > > > >> response.write(pdf.output(dest='S'), escape=False) > > > > >> }} > > > > >> ---- end file--- > > > > >> At MyFPDF class you can add headers and footers. > > > > >> The sanitize part is to strip some HTML tags that cannot be rendered > > > >> (ie. javascript). > > > > >> As some DIVs contents and similar may still pass (like menus), a > > > >> better alternative may be render only certains portions of the page in > > > >> a custom view: > > > > >> pdf.write_html(str(XML(CENTER(section), sanitize=False))) > > > > >> Best regards, > > > > >> Mariano > > > >> Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.com