PDF writing under GAE

已查看 347 次
跳至第一个未读帖子

Arbie Samong

未读,
2011年4月4日 10:08:102011/4/4
收件人 web2py-users
Did anyone figure out how to let users download pdf's that contains
data from the database under GAE? Appengine does not allow file
writing, and most pdf writing libraries I've tried involves
temporarily writing in the disk.

Massimo Di Pierro

未读,
2011年4月4日 10:10:342011/4/4
收件人 web2py-users
does myfpdf require file writing? I did not check? If it does it
should be easy to change it to use a StringIO instead.

Arbie Samong

未读,
2011年4月4日 10:15:042011/4/4
收件人 web2py-users
When trying it out on localhost:8080 using the appengine sdk it
returns an IO error pointing out that writes aren't allowed. I'll be
looking into StringIO, thanks for the tip Massimo

Regards,
Arbie

On Apr 4, 10:10 pm, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:

Arbie Samong

未读,
2011年4月4日 10:30:092011/4/4
收件人 web2py-users
OK what I'm trying right now is something straight out of the wiki:

html = response.render('default/download.html', locals())

class MyFPDF(FPDF, HTMLMixin):
def header(self):
self.set_font('Arial','B',15)
self.cell(0,10, response.title ,1,0,'C')
self.ln(20)

def footer(self):
self.set_y(-15)
self.set_font('Arial','I',8)
txt = 'Page %s of %s' % (self.page_no(), self.alias_nb_pages())
self.cell(0,10,txt,0,0,'C')

pdf.add_page()
pdf.write_html(html)
response.headers['Content-Type']='application/pdf'
return pdf.output(dest='S')

and it gives the error:
RuntimeError: FPDF error: PIL not installed

in which I copied the PIL/ folder from /usr/lib/python2.6/dist-
packages/PIL to the web2py/site-packages/ folder and no effect. PIL is
already installed in the system, as well as in the virtualenv I'm
using.

Regards,
Arbie

Arbie Samong

未读,
2011年4月4日 10:35:192011/4/4
收件人 web2py-users
OK update, PIL is being required because I have an image tag in my
view, I removed the tag and the pdf was downloaded fine. Would love to
have images written properly, though.

Regards,
Arbie

Arbie Samong

未读,
2011年4月4日 11:21:592011/4/4
收件人 web2py-users
Follow-up question, how do I get PIL to be recognized as installed? I
tried easy_install on the whole system, then on the virtual env, then
copying the PIL/ folder to site-packages, but nothing seems to work.

Thanks,
Arbie

Martín Mulone

未读,
2011年4月4日 11:56:542011/4/4
收件人 web...@googlegroups.com
Perhaps changing this line in fpdf:


with this one work

from google.appengine.api import images


2011/4/4 Arbie Samong <phe...@gmail.com>
已删除帖子

howesc

未读,
2011年4月4日 15:11:362011/4/4
收件人 web...@googlegroups.com、mar...@tecnodoc.com.ar
hopefully not a red herring, but google gave us gifts last week, one of them was file "reading" and "writing" from the blobstore: http://googleappengine.blogspot.com/2011/03/announcing-app-engine-143-release_30.html

i have not looked at how to connect things to it, but might help here.

cfh

Arbie Samong

未读,
2011年4月5日 00:52:512011/4/5
收件人 web2py-users
@martin - that helped me passed the try-except block at the beginning,
but when the Image module is used on the other parts of the code it
went haywire. I'll look into it probably more changes to make it adapt
with GAE.

@howesc - I was able to make it work without using the file system
read and write, but this is like heaven sent :)

On Apr 5, 3:11 am, howesc <how...@umich.edu> wrote:
> hopefully not a red herring, but google gave us gifts last week, one of them
> was file "reading" and "writing" from the blobstore:http://googleappengine.blogspot.com/2011/03/announcing-app-engine-143...

Martín Mulone

未读,
2011年4月5日 06:19:402011/4/5
收件人 web...@googlegroups.com
Well I browse the code of fpdf.py and pil is only using to check is the file is and image format, I think is easy to do to support gae, changing in gae to api or make the check like IS_IMAGE from web2py.

Anyways there are other tools you can use to write pdf reports like PISA, Reportlab.

2011/4/5 Arbie Samong <phe...@gmail.com>

contatog...@gmail.com

未读,
2011年4月5日 08:47:502011/4/5
收件人 web...@googlegroups.com
There's this plugin for web2pyhttps://github.com/lucasdavila/appreport
__________________________________ ___________
Gilson Filho

Massimo Di Pierro

未读,
2011年4月5日 09:15:202011/4/5
收件人 web2py-users
It would be nice if fpdf were to work on GAE out of the box. Moreover
I think PIL is available on GAE.

On Apr 5, 5:19 am, Martín Mulone <mulone.mar...@gmail.com> wrote:
> Well I browse the code of fpdf.py and pil is only using to check is the file
> is and image format, I think is easy to do to support gae, changing in gae
> to api or make the check like IS_IMAGE from web2py.
>
> Anyways there are other tools you can use to write pdf reports like PISA,
> Reportlab.
>
> 2011/4/5 Arbie Samong <phek...@gmail.com>

andrej burja

未读,
2011年4月6日 02:25:262011/4/6
收件人 web2py-users
hi

pyftpdf (included in web2py) does not have unicode support
does anybody know are there some unicode problems in reportlab too?
maby font problems?

i would like to see code example for reportlab on gae (since the
example in the book does not work :)

andrej


On Apr 5, 3:15 pm, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:
> > Expert4Solution:http://www.experts4solutions.com/e4s/default/expert/6http://www.cvsta...
回复全部
回复作者
转发
0 个新帖子