django and and pisa are great for creating PDF's because you can
combine django's templating engine with pisa's HTML to PDF conversion.
Pisa uses the reportlab tool kit. http://pypi.python.org/pypi/pisa/

Example:

import ho.pisa as pisa
import cStringIO as StringIO

from django.template.loader import get_template
from django.template import Context

def generatePDF(data):
    template = get_template(path/to/pdf.html')
    html = template.render(Context({
        'data':data
    }))

    result = StringIO.StringIO()
    pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")),
result)

    return result.getvalue()


You can then do what you want with the PDF value. Send it as a
download, attach to email or save to disk.

Example response for download via a web browser

response = HttpResponse(generatePDF(data), mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=afilename.pdf'
return response


Hope that helps.




On Apr 20, 5:59 pm, Alessandro Ronchi <alessandro.ron...@soasi.com>
wrote:
> I need to create some brochures on the fly (with texts and images with
> different position from my templates) in pdf with django.
> What's the best solution?
> Reportlab?
>
> I don't have any license problem (I can buy the software if it suites
> my needs),  and I must generate quality pdf (for use in typography)
> with a some images (raster and bitmap) in my web application.
>
> I want to use django as web framework.
>
> Any use case? Or documentation I can read?
>
> Thanks in advance, best regards.
> --
> Alessandro Ronchi
>
> http://www.soasi.com
> SOASI - Sviluppo Software e Sistemi Open Source
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to