thanks anthony!!

works!

but one more thing, is it possible create a rtf template and send
parameters to the template?

rgsd,

Diego


2013/12/30 Anthony <[email protected]>

> Sorry, a couple mistakes in the code. This should do it:
>
> 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 )
>
>
>     s = cStringIO.StringIO()
>     Renderer().Write(doc, s)
>     s.seek(0)
>     return response.stream(s, attachment= True, filename=
> 'yourdocument.rtf')
>
> Anthony
>
> On Monday, December 30, 2013 7:52:07 AM UTC-5, Diego Tostes wrote:
>
>> thanks anthony,
>>
>> but did not works... the result was a file with no name with "None"
>> printed at the first page....
>>
>>
>> 2013/12/29 Anthony
>>
>>> 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 )
>>>
>>>     s = cStringIO.StringIO()
>>>     Renderer().Write(doc, s)
>>>     s.seek(0)
>>>     return response.stream(s, attachment= True, 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 <[email protected]>
>>>>
>>>>> 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 <[email protected]>
>>>>>
>>>>>> 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 <[email protected]>
>>>>>>>
>>>>>>> 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 [email protected].
>>>>>>
>>>>>> 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 [email protected].
>>> 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to