Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
PDF Generation
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
David Cifuentes  
View profile  
 More options May 12 2008, 9:36 pm
From: David Cifuentes <david.cifuen...@eforcers.com>
Date: Mon, 12 May 2008 18:36:59 -0700 (PDT)
Local: Mon, May 12 2008 9:36 pm
Subject: PDF Generation
Hi all,

I'm trying to add to my app engine project functionality for exporting
as a PDF file. I'm trying to use the ReportLab library
http://www.reportlab.org/downloads.html and I'm also following the
tutorial in http://www.devshed.com/c/a/Python/Python-for-PDF-Generation/
mixed with the example in http://www.djangoproject.com/documentation/outputting_pdf/

But when I save the file I get the following error inside the PDF
document:

Traceback (most recent call last):
  File "C:\Archivos de Programa\Google\google_appengine\google
\appengine\ext\webapp\__init__.py", line 499, in __call__
    handler.get(*groups)
  File "C:\ecv.eforcers.com\ecv\src\handler\fin.py", line 40, in get
    pdf.save()
  File "C:\ecv.eforcers.com\ecv\reportlab\pdfgen\canvas.py", line 877,
in save
    self._doc.SaveToFile(self._filename, self)
  File "C:\ecv.eforcers.com\ecv\reportlab\pdfbase\pdfdoc.py", line
218, in SaveToFile
    f = open(filename, "wb")
  File "C:\Archivos de Programa\Google\google_appengine\google
\appengine\tools\dev_appserver.py", line 736, in __init__
    raise IOError('invalid mode: %s' % mode)
IOError: invalid mode: wb

It looks like I'm violating the condition to write on the filesystem,
even if I try the http response as a file.

Here is my code...

import cgi
import wsgiref.handlers
import logging

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext import db

import os
from google.appengine.ext.webapp import template

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib.units import cm, mm, inch, pica

from django.http import HttpResponse

class FinHandler(webapp.RequestHandler):
  def get(self, id_persona=None):
    logging.debug("Entrando a generar el PDF para la persona %s",
id_persona)

    # Create the HttpResponse object with the appropriate PDF headers.
    self.response.headers.add_header("Content-Type", "application/
pdf")
    self.response.headers.add_header("Content-Disposition",
"attachment; filename=cv.pdf")
    # Create the PDF object, using the response object as its "file."
    pdf = canvas.Canvas(self.response)
    # Draw things on the PDF. Here's where the PDF generation happens.
    # See the ReportLab documentation for the full list of
functionality.
    pdf.setFont("Courier", 60)
    pdf.setFillColorRGB(1, 0, 0)
    pdf.drawCentredString(letter[0] / 2, inch * 6, "CLASSIFIED")
    pdf.setFont("Courier", 30)
    pdf.drawCentredString(letter[0] / 2, inch * 5, "For Your Eyes
Only")
    # Close the PDF object cleanly, and we're done.
    pdf.showPage()
    pdf.save()

Please, if any of you have implemented this functionality with
ReportLab or a different library I would appreciate any help. Thanks

David C


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Cifuentes  
View profile  
(1 user)  More options May 12 2008, 9:51 pm
From: David Cifuentes <david.cifuen...@eforcers.com>
Date: Mon, 12 May 2008 18:51:17 -0700 (PDT)
Local: Mon, May 12 2008 9:51 pm
Subject: Re: PDF Generation
Sorry!!

Didn't search enough. I found the answer in:

http://konryd.blogspot.com/2008/04/outputting-pdfs-with-google-app-en...

I hope this helps people with the same problem...

David C.

On 12 mayo, 20:36, David Cifuentes <david.cifuen...@eforcers.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aral Balkan  
View profile  
 More options May 20 2008, 4:00 pm
From: Aral Balkan <aralbal...@gmail.com>
Date: Tue, 20 May 2008 13:00:04 -0700 (PDT)
Local: Tues, May 20 2008 4:00 pm
Subject: Re: PDF Generation
Hi David,

Thank you for sharing the link -- looks handy :)

Aral

On May 13, 2:51 am, David Cifuentes <david.cifuen...@eforcers.com>
wrote:

> Sorry!!

> Didn't search enough. I found the answer in:

> http://konryd.blogspot.com/2008/04/outputting-pdfs-with-google-app-en...

> I hope this helps people with the same problem...

> David C.

<snip>

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Devraj Mukherjee  
View profile  
 More options May 20 2008, 6:17 pm
From: "Devraj Mukherjee" <dev...@gmail.com>
Date: Wed, 21 May 2008 08:17:56 +1000
Local: Tues, May 20 2008 6:17 pm
Subject: Re: [google-appengine] Re: PDF Generation
I have also always wondered if its possible to use Google docs to do
this for you. So you upload a doc to the Google doc engine and
download it back as a PDF.

Although GData doesn't yet support downloading of docs programmtically
this could be a viable option for the future.

--
"I never look back darling, it distracts from the now", Edna Mode (The
Incredibles)

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Filip  
View profile  
 More options May 22 2008, 8:20 am
From: Filip <filip.verhae...@gmail.com>
Date: Thu, 22 May 2008 05:20:56 -0700 (PDT)
Local: Thurs, May 22 2008 8:20 am
Subject: Re: PDF Generation
Actually, if you could download a Google Doc using GData as PDF, you
could parse it, create a table of contents and insert it in the
original document. That would be cool. The main feature missing from
Google Docs for me is automatic table-of-content generation.

Filip.

On 21 mei, 00:17, "Devraj Mukherjee" <dev...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google