Ok, 'm really liking this! a few questions:
1) I'm not catching on where we get pdflatex... is it a plugin? where do we get it? 2) Is this a feature that can be add to an up for users? meanin something like "upload your document - then download your pdf (or email generated pdf")? should be doable? 3) I used reportlab for drawing fingerboard templates for kids learning the violin (which I got some nasty email from some template maker/vendor, so now I really want to put this out there - its just number crunching so it should be a crome to sell numbers to kids ;) ) Is here a way to make use of those drawing capabilities? simple: draw lines @ coordinates? 4) scaling: is there a way to control that at this end? (for printing purposes - scaling needs to be disabled) thanks :) On Oct 3, 12:28 am, mdipierro <[email protected]> wrote: > or better > > {{ > 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=='p': return text+'\n\n' > if tag=='li': return '\n- '+text.replace('\n',' ') > if tag=='tr': return text[3:].replace('\n',' ')+'\n' > if tag in ['table','blockquote']: return '\n-----\n'+text+'\n------ > \n' > if tag in ['td','th']: return ' | '+text > if tag in ['b','strong','label']: return '**%s**' % text > if tag in ['em','i']: return "''%s''" % text > if tag in ['tt','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) > pdf,warnings,errors=markmin2pdf(markmin) > if errors: > response.headers['Content-Type']='text' > > response.write(HTML(BODY(H1('errors'),LU(*errors),H1('warnings'),LU(*warnings)))) > else: > response.headers['Content-Type']='application/pdf' > response.write(pdf,escape=False) > pass > > }} > > On Oct 2, 11:10 pm, mdipierro <[email protected]> wrote: > > > 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 > >

