In trunk, web2py tries to use markmin2pdflatex is installed. If not it uses pyfpdf. pyfpdf fails on some html, for example if table do not follow the pyfpdf specs. I believe Marino is working on making pyfpdf more forgiving.
Massimo On May 29, 10:39 pm, Christopher Steel <chris.st...@gmail.com> wrote: > I am going try things out again when I get a chance. This stuff is > just great. I love the fact that we build on a solid API so in the end > we get the GUI and command line and API access for developers and the > blind. It totally rocks!!! > > Markmin to PDF would be very interesting as well.. > > Chris > > On May 27, 12:08 pm, Mariano Reingart <reing...@gmail.com> wrote: > > > > > > > > > Regarding PyFPDF: > > > Headers should be rendered. > > > Tables need at least a first TH, prior any TD, who indicates column > > width (and it is wise to use THEAD and TBODY when you have multiple > > pages), see:http://code.google.com/p/pyfpdf/wiki/WriteHTML > > > <table border="0" align="center" width="50%"> > > <thead><tr><th width="30%">Header 1</th><th width="70%">header > > 2</th></tr></thead> > > <tbody> > > <tr><td>cell 1</td><td>cell 2</td></tr> > > <tr><td>cell 2</td><td>cell 3</td></tr> > > </tbody> > > </table> > > > I'm planning to fix this issues, to cover more basic html conversions. > > > You can see what can do pyfpdf in this > > file:http://pyfpdf.googlecode.com/files/html.pdf > > > BTW, did you see the new visual designer of pdf templates? > > >http://code.google.com/p/pyfpdf/wiki/Templates?ts=1306512231&updated=... > > > It is a wx application, and I'm planning to connect it using DAL to > > ease template/report generation (I think this is much easier and > > manageable way than converting html). > > > Best regards, > > > Mariano Reingarthttp://www.sistemasagiles.com.arhttp://reingart.blogspot.com > > > On Fri, May 27, 2011 at 1:35 AM, Massimo Di Pierro > > > <massimo.dipie...@gmail.com> wrote: > > > 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