[Zope] Generating and Downloading PDF[Solved]

Fernando Lujan flujan at gmail.com
Fri May 13 12:43:28 EDT 2005


Chris Withers wrote:

> Um? What else is that method returning?
> I'd suggest you call getrarTCE directly by URL, check you're setting 
> the correct content-type and maybe set a content disposition too...


Solved. :) I create a External Method that returns the code.

I'm calling the external method using:
       <dtml-var "generatePDF(REQUEST.response)">

And I put the following lines at the end of the code:

fname stands for the filename

def generatePDF(page):

	os.rename(_fname, "tces/"+_fname)
	file = open("tces/"+_fname).read()
	os.remove("tces/"+_fname)
	page.setHeader('content-type', 'x-application/pdf')
	page.setHeader('content-length', str(len(file)))
	page.write(file)

This was the best solution that I could thought, once reportlab didn't create PDF "on the fly", without writing in the filesystem.



More information about the Zope mailing list