if there are errors it should return text containing the errors, else pdf. This mechanism for error reporting is temporary and does not quite work.
On Oct 3, 3:02 pm, Michele Comitini <[email protected]> wrote: > @Massimo, > > is it text? > > response.headers['content-type']='text' > > or > > response.headers['content-type']='application/pdf' ? > > tnx > mic > > 2010/10/3 mdipierro <[email protected]>: > > > install pdflatex > > > create a views/generic.pdf that contains: > > > ---- begin file ---- > > {{ > > import re > > from gluon.contrib.markmin.markmin2pdf import markmin2pdf > > def markmin_serializer(text,tag=None,attr={}): > > if tag==None: return re.sub('\s+',' ',text) > > if tag=='br': return '\n\n' > > if tag=='h1': return '# '+text+'\n\n' > > if tag=='h2': return '#'*2+' '+text+'\n\n' > > if tag=='h3': return '#'*3+' '+text+'\n\n' > > if tag=='h4': return '#'*4+' '+text+'\n\n' > > if tag=='li': return '\n- '+text.replace('\n',' ') > > if tag=='table': return '\n-----\n'+text+'\n------\n' > > if tag=='tr': return text[3:].replace('\n',' ')+'\n' > > if tag=='td': return ' | '+text > > if tag=='p': return text+'\n\n' > > if tag=='b' or tag=='strong': return '**%s**' % text > > if tag=='em' or tag=='i': return "''%s''" % text > > if tag=='tt' or tag=='code': return '``%s``' % text > > if tag=='a': return '[[%s %s]]' % (text,attr.get('_href','')) > > return text > > html=response.render('%s/%s.html' % > > (request.controller,request.function)) > > markmin=TAG(html).element('#content').flatten(markmin_serializer) > > response.write(markmin2pdf(markmin)[0],escape=False) > > response.headers['content-type']='text' > > }} > > ---- end file--- > > > Now you should be able to view any web2py page with .pdf in pdf. > > > I am sure this can also be done and better with pyfpdf but I have not > > tried. Perhaps Mariano can help us > >

