Skip to content

RTFDE: RTF De-Encapsulator - A python3 library for extracting encapsulated `HTML` & `plain text` content from the `RTF` bodies of .msg files.

License

Notifications You must be signed in to change notification settings

TheElementalOfDestruction/RTFDE

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RTFDE: RTF De-Encapsulator

A python3 library for extracting encapsulated HTML & plain text content from the RTF bodies of .msg files.

De-encapsulation enables previously encapsulated HTML and plain text content to be extracted and rendered as HTML and plain text instead of the encapsulating RTF content. After de-encapsulation, the HTML and plain text should differ only minimally from the original HTML or plain text content.

Features

  • De-encapsulate HTML from RTF encapsulated HTML.
  • De-encapsulate plain text from RTF encapsulated text.

Known Issues

  • This library fully unquotes text it de-encapsulates because it does not know which text was quoted in the RTF conversion process and which text was quoted in the original html/text. So, for instance escaped Quoted-Printable text will be returned un-escaped.
  • This library currently can't combine attachments from a .MSG Message object with the de-encapsulated HTML. This is mostly because I could not get a good set of examples of encapsulated HTML which had attachment objects that needed to be integrated back into the body of the HTML.

Anti-Features (I don't intend to have this library do this.)

  • Extract plain text from RTF encapsulated HTML. If you want this, then you will have to parse the HTML using another library.

Installation

To install from the pip package.

pip3 install RTFDE

Usage

De-encapsulating HTML or TEXT

from RTFDE.deencapsulate import DeEncapsulator

with open('rtf_file', 'r') as fp:
    raw_rtf  = fp.read()
    rtf_obj = DeEncapsulator(raw_rtf)
    rtf_obj.deencapsulate()
    if rtf_obj.content_type == 'html':
        print(rtf_obj.html)
    else:
        print(rtf_obj.text)

Contribute

Please check the contributing guidelines

License

Please see the license file for license information on RTFDE. If you have further questions related to licensing PLEASE create an issue about it on github.

About

RTFDE: RTF De-Encapsulator - A python3 library for extracting encapsulated `HTML` & `plain text` content from the `RTF` bodies of .msg files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 91.9%
  • Rich Text Format 8.1%