You are attempting to return a pyrtf.Document object, but instead you must 
stream a file or file-like object. You have to render the document to a 
file-like object and use response.stream():

def generate_doc():
    from gluon.contrib.pyrtf import *
    import cStringIO
    
    doc     = Document()
    ss      = doc.StyleSheet
    section = Section()
    doc.Sections.append( section )
    
    p = Paragraph( ss.ParagraphStyles.Heading1 )
    p.append( 'Certified Staff Evaluation' )
    section.append( p )
    response.stream(pyrtf.Renderer().Write(doc, cStringIO.StringIO()),
                    filename='yourdocument.rtf')

Specifying the filename with the ".rtf" extension ensures the content-type 
header will be set properly automatically.

Anthony

On Saturday, December 28, 2013 4:20:34 PM UTC-5, Diego Tostes wrote:
>
> here is my code:
>
> http://pastebin.com/qh5AV8Xh
>
> but the download don't start when i access this controler.
>
>
>
>
>
>
> 2013/12/28 Diego Tostes <tostes...@gmail.com <javascript:>>
>
>> i am using the pyrtf, but i dont know how create the file and download 
>> without save the file on the server.
>>
>> any idea?
>>
>>
>> 2013/12/28 Anthony <abas...@gmail.com <javascript:>>
>>
>>> There's also python-docx <https://github.com/mikemaccana/python-docx>.
>>>
>>>
>>> On Saturday, December 28, 2013 10:35:33 AM UTC-5, Diego Tostes wrote:
>>>
>>>> done using 
>>>> PyRTF
>>>>
>>>>
>>>> thanks
>>>>
>>>>
>>>> 2013/12/28 Diego Tostes <tostes...@gmail.com>
>>>>
>>>> Hi,
>>>>>
>>>>> Is it possible create doc files (word or openoffice) using templates 
>>>>> rendering?
>>>>>
>>>>> Rgds,
>>>>>
>>>>> Diego
>>>>>
>>>>
>>>>  -- 
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to web2py+un...@googlegroups.com <javascript:>.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to