[Zope] Generating and Downloading PDF.
Fernando Lujan
flujan at uol.com.br
Thu Apr 28 15:37:40 EDT 2005
J Cameron Cooper wrote:
> It's easier to guess when you say what the problem is.
>
> I do see some funny indentation down at the bottom.
OK, it's happen because I paste the code inside a html message, than
it's happen.
The following code is working. But I still have a problem. The browser (
firefox ) don't reconize the generated document as a PDF.
I'm calling this external method through a <dtml-var "gerar_tce_pdf()">
tag, inside a DTML DOCUMENT.
def gerarTCE(self):
from reportlab.pdfgen import canvas
import string
import os
c = canvas.Canvas("hello.pdf")
c.drawString(100,100,"Hello World")
c.showPage()
c.save()
arquivo = open("hello.pdf").read()
R = self.REQUEST.RESPONSE
R.setHeader('content-type', 'application/pdf')
R.setHeader('content-length', str(len(arquivo)))
R.write(arquivo)
Thanks for helping... :)
Fernando Lujan
More information about the Zope
mailing list