On 28 abr, 12:52, Jose <jjac...@gmail.com> wrote:
> Since I adapt the following code from Django to Web2py:
>
> from reportlab.pdfgen import canvas
> from django.http import HttpResponse
>
> def some_view(request):
>     # Create the HttpResponse object with the appropriate PDF headers.
>     response = HttpResponse(mimetype='application/pdf')
>     response['Content-Disposition'] = 'attachment;
> filename=somefilename.pdf'
>
>     # Create the PDF object, using the response object as its "file."
>     p = canvas.Canvas(response)
>
>     # Draw things on the PDF. Here's where the PDF generation happens.
>     # See the ReportLab documentation for the full list of
> functionality.
>     p.drawString(100, 100, "Hello world.")
>
>     # Close the PDF object cleanly, and we're done.
>     p.showPage()
>     p.save()
>     return response
>
> Regards
> Jose
>
> ref:http://docs.djangoproject.com/en/dev/howto/outputting-pdf/

this one is the response:

def some_view():
    response.headers['Content-Type']='application/pdf'
    response.headers['Content-Disposition'] = 'attachment;
filename=somefilename.pdf'

    buffer = StringIO()
    p = canvas.Canvas(buffer)
    p.drawString(100, 100, "Hello world.")
    p.showPage()
    p.save()
    pdf = buffer.getvalue()
    buffer.close()

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

Reply via email to