{"id":2444,"library":"compressed-rtf","title":"Compressed RTF","description":"Compressed Rich Text Format (RTF) compression and decompression package. It supports the LZFu compression format, based on the Microsoft RTF Compression Algorithm. The current version is 1.0.7, and releases are infrequent, primarily for bug fixes.","status":"active","version":"1.0.7","language":"en","source_language":"en","source_url":"https://github.com/delimitry/compressed_rtf","tags":["compression","rtf","text-processing","microsoft"],"install":[{"cmd":"pip install compressed-rtf","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Used to compress RTF byte data.","symbol":"compress","correct":"from compressed_rtf import compress"},{"note":"Used to decompress RTF byte data.","symbol":"decompress","correct":"from compressed_rtf import decompress"}],"quickstart":{"code":"from compressed_rtf import compress, decompress\n\n# Example RTF data (must be bytes)\nrtf_data = b'{\\rtf1\\ansi\\ansicpg1252\\deff0\\nouicompat\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Calibri;}{\\f1\\fnil\\fcharset2 Symbol;}}\n{\\pard\\sa200\\sl276\\slmult1\\f0\\fs22\\lang9 This is some \\b compressed\\b0  RTF data.\\par}\n}\n'\n\n# Compress the data\ncompressed_bytes = compress(rtf_data)\nprint(f\"Original size: {len(rtf_data)} bytes\")\nprint(f\"Compressed size: {len(compressed_bytes)} bytes\")\n\n# Decompress the data\ndecompressed_bytes = decompress(compressed_bytes)\n\n# Verify decompression\nassert decompressed_bytes == rtf_data\nprint(\"Decompression successful!\")\nprint(f\"Decompressed content: {decompressed_bytes.decode('ascii', errors='ignore')[:50]}...\")","lang":"python","description":"Demonstrates how to compress and decompress RTF byte data using the `compress` and `decompress` functions."},"warnings":[{"fix":"Ensure that the RTF data you are processing conforms to the LZFu compression scheme used by Microsoft products. For general compression, consider Python's built-in `zlib` or `gzip` modules.","message":"This library implements the specific Microsoft Rich Text Format (RTF) Compression Algorithm (LZFu) outlined in MS-OXRTFCP. It is not a general-purpose compression library and should not be confused with standard Python compression modules like `zlib` or `gzip`.","severity":"gotcha","affected_versions":"<1.0.7"},{"fix":"Upgrade to version 1.0.7 or later to benefit from packaging stability fixes: `pip install --upgrade compressed-rtf`.","message":"Version 1.0.7 resolved a circular import issue in `setup.py` (Pull Request #19) that could affect packaging and installation in certain environments. While not a direct API breaking change, users on older versions (<=1.0.6) might encounter installation or build issues.","severity":"gotcha","affected_versions":"<1.0.7"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}