usr bin python encoding cp1251 PyRyRTF http dumpz org 2013 example imp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python
# encoding: cp1251
# PyRyRTF (http://dumpz.org/2013/) example
import PyRuRTF as rtf
def make_doc():
doc = rtf.RussianDocument()
style = doc.StyleSheet
section = rtf.Section()
doc.Sections.append(section)
section.append('Пример 1')
section.append('')
section.append( 'Пример русского текста. '
'Используется 8-битный текст в кодировке cp1251.')
return doc
def save_doc(filename):
doc = make_rtf()
renderer = rtf.RussianRenderer()
renderer.Write(doc, open(filename, 'w'))
if __name__ == '__main__':
save_doc('fee.rtf')