Skip to content

A fork of PyRTF, pyrtf-ng aims to be more efficient and adhere to the subset of PEP-8 standard as dictated by the Twisted coding standard, provide Rich Text Format file parsing, while still enabling users to generate RTF files from Python.

License

brunetton/python-rtfng

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic examples

Hello World

from rtfng.Elements import Document, Section

doc = Document()
section = Section()
section.append('Hello world !')
doc.Sections.append(section)

doc.write(file('hello.rtf', 'w'))

Example 1

from rtfng.Elements import Document, Section
from rtfng.document.paragraph import Paragraph
from rtfng.document.character import TEXT

# Init
doc = Document()
section = Section()

# First paragraph
p = Paragraph()
p.append('It is also possible to manully override a style:',
          TEXT(' this is a change of the font size', size=48),
         '.')
section.append(p)

# Empty paragraph
section.append('')

# Second paragraph
p = Paragraph()
p.append('This is a ',
          TEXT('very important information !', colour=doc.StyleSheet.Colours.Red, underline=True, bold=True)
        )
# Have a look to TEXT() definition in rtfng/document/character.py for more options

section.append(p)
doc.Sections.append(section)

doc.write(file('example.rtf', 'w'))

Tests

For example usage, see the code in the unit tests in the 'test' directory and its subdirectories.

To run all tests:

python test/test_all.py
python test/test_doctests.py

About

A fork of PyRTF, pyrtf-ng aims to be more efficient and adhere to the subset of PEP-8 standard as dictated by the Twisted coding standard, provide Rich Text Format file parsing, while still enabling users to generate RTF files from Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.0%
  • Shell 4.0%