|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Easy PDF generation using PISA HTML2PDFHi, I'm the author of a pure Python module that is able to generate PDF form HTML and CSS. You find more informations about it and a sample integration in Django here: http://www.htmltopdf.org I think this could be interesting to be mentioned in your documentation: http://www.djangoproject.com/documentation/outputting_pdf/ As I do not use Django often, the sample may be not very complete. A user of my tool send me this portion of code that should help you integration pisa into your work: #! /usr/bin/python # -*- encoding: utf-8 -*- from django.template.loader import get_template from django.template import Context from django.http import HttpResponse import cStringIO as StringIO from sx.pisa3 import pisaDocument def html_to_pdf(content): ''' Convert the html content to PDF ''' result = StringIO.StringIO() html = StringIO.StringIO(content.encode("ISO-8859-1")) pdf = pisaDocument(html, result) if not pdf.err: return result.getvalue() return pdf def render_to_pdf(template_src, context_dict): ''' Render the template with a context. Then send the response in pdf format. ''' template = get_template(template_src) context = Context(context_dict) html = template.render(context) return HttpResponse(html_to_pdf(html), 'application/pdf', 200,'application/pdf') Hope this informations are helpful for you. Regards, Dirk --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@... To unsubscribe from this group, send email to django-users-unsubscribe@... For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Easy PDF generation using PISA HTML2PDFHi, I updated pisa which now includes a complete Django example. http://pypi.python.org/pypi/pisa/3.0.17 Enjoy it. Dirk --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@... To unsubscribe from this group, send email to django-users-unsubscribe@... For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Easy PDF generation using PISA HTML2PDFThanks ! Easier than reportlab :) Greg On Mar 23, 7:37 pm, "dirk.holtw...@..." <dirk.holtw...@...> wrote: > Hi, > > I updated pisa which now includes a complete Django example. > > http://pypi.python.org/pypi/pisa/3.0.17 > > Enjoy it. > Dirk --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@... To unsubscribe from this group, send email to django-users-unsubscribe@... For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Easy PDF generation using PISA HTML2PDFI have used html2pdf in the past and it is awfully easy! In one of my apps, I had a requirement that each page be also available as pdf. so def view_func(self): ..normal processing if request.GET.has_key('pdf'): #Get the pdf template html = StringIO.StringIO(template.render(Context(payload))) result = StringIO.StringIO() pdf = pisa.CreatePDF(html, result) return HttpResponse(result.getvalue(), mimetype='application/ pdf') On Mar 24, 2:25 am, coulix <cou...@...> wrote: > Thanks ! > Easier than reportlab :) > Greg > > On Mar 23, 7:37 pm, "dirk.holtw...@..." > > <dirk.holtw...@...> wrote: > > Hi, > > > I updated pisa which now includes a complete Django example. > > >http://pypi.python.org/pypi/pisa/3.0.17 > > > Enjoy it. > > Dirk You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@... To unsubscribe from this group, send email to django-users-unsubscribe@... For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |