On Tue, Apr 13, 2010 at 11:55 AM, Krishnakant Mane <[email protected]> wrote:
> On Tuesday 13 April 2010 11:59 PM, Deron Meranda wrote:
>>
>> You can send the PDF just as you would any other type of
>> *binary* file, such as an image....do not attempt to process
>> it as text.  Use the content-type header of "application/pdf".
>>
>>
>
> Where do I set this header in context to a pylons controller action?
> Should I do it in the respective method from where the pdf file is to be
> rendered?

You'd normally do this in the action method, but you can do it
anywhere where 'response' is available.

> Another question is that should I use return render(/report.mako) or is
> there some thing different I will have to do once I set the response header
> to "application/pdf"?

You return the content of the PDF document. That would be whatever
ReportLab outputs.

render() is just a convenience function to format the output with a
template. It *can* be used for non-HTML output, but is not very likely
for formats like PDF.

> No, the pdf files are going to be 1 page or in rare cases at the most 2
> pages.
> And by any chance is some thing similar possible for open office
> spreadsheets?

Deron wrote:
> If you don't need much except rows and columns, your easiest choice is to 
> just serve up CSV files.

Yes, CSV files are the most convenient way to import/export spreadsheets.

However, you can send an Open Office XML document if you can find a
library that generates the right syntax. There may be a Python library
in Open Office or in a contrib repository or in PyPI to do that.

The main point for Pylons is, you can send any multimedia type, you
just have to set 'response.content_type' correctly, and return the
content in its appropriate format. Or if it's already in a file, use
paste.fileapp .

-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to