RTFDE (RTF De-Encapsulator) is a Python library designed to extract HTML content from RTF-encapsulated HTML, a common format found within Exchange MSG email files. It provides robust parsing and de-encapsulation capabilities, focusing on raw byte input. The library is currently at version 0.1.2.2 and receives active maintenance with regular bug fixes and minor updates.
pip install rtfdeVerified import paths — ran on the pinned version, not inferred.
Initialize the DeEncapsulator and pass RTF content as bytes to the `deencapsulate` method to extract the embedded HTML. The library handles the parsing and extraction of the 'htmlrtf' section.
Ensure all RTF input is converted to `bytes` (e.g., `my_rtf_string.encode('utf-8')`) before being passed to `DeEncapsulator.deencapsulate`.Upgrade to version 0.1.2.2 or newer to benefit from the fix for invalid Unicode escape sequence handling.
Implement robust error handling around `de.deencapsulate()` and validate the extracted HTML content. Consider preprocessing or sanitizing the RTF source if its integrity is frequently questionable.