We have found a simple solution... this code do the trick:
{{
import xhtml2pdf.pisa as pisa
filename = '%s/%s.html' % (request.controller,request.function)
html = response.render(filename)
pdf = pisa.CreatePDF(html, dest = response.body)
}}
We hope to be of any help to other people with the same problem
Cheers
Manuele
On 05/12/2018 12:13, Manuele Pesenti wrote:
Hi!
we are trying to build up printable report from a view. We'd like to
use xhtml2pdf instead using the web2py embedded library fpdf.
How the view template file should look like?
Essentially we tried something like the following without success:
{{
from xhtml2pdf import pisa
from StringIO import StringIO
filename = '%s/%s.html' % (request.controller,request.function)
html=response.render(filename)
dest = StringIO()
# convert HTML to PDF
pisaStatus = pisa.CreatePDF(html, dest=dest)
="ERROR" if not pisaStatus else dest.getvalue()
}}
--
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/d/optout.