{"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":"python","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,"search_vec":"'1.0.7':29 'algorithm':24 'base':18 'bug':36 'compress':1,3,8,16,23,38 'current':26 'decompress':10 'fix':37 'format':6,17 'infrequ':33 'lzfu':15 'microsoft':21,43 'packag':11 'primarili':34 'process':42 'releas':31 'rich':4 'rtf':2,7,22,39 'support':13 'text':5,41 'text-process':40 'version':27","created_at":"2026-04-11T01:28:24.283352+00:00","updated_at":"2026-04-16T03:25:03.956506+00:00","problems":[{"fix":"Ensure the package is installed using pip: `pip install compressed-rtf`","cause":"The `compressed-rtf` package is not installed in your current Python environment, or there is a typo in the import statement.","error":"ModuleNotFoundError: No module named 'compressed_rtf'"},{"fix":"Try updating `pip` and `setuptools` (`pip install --upgrade pip setuptools`). If the issue persists, ensure you have C++ build tools for Python installed (e.g., from Visual Studio Build Tools). A direct fix for the reported upstream issue may require using a pre-compiled wheel or a different environment.","cause":"This error often occurs during installation on Windows, indicating a problem with building the package's metadata, potentially due to missing C++ build tools or an upstream compatibility issue with the `compressed-rtf` package itself on Windows.","error":"error: metadata-generation-failed × Encountered error while generating package metadata."},{"fix":"Ensure the data passed to `decompress()` is a byte string obtained from a legitimate compressed RTF source. Verify the integrity of your input data. You might need to inspect the first few bytes of your input to confirm it matches the expected RTF compression signatures (e.g., '#\\x00\\x00\\x00\"\\x00\\x00\\x00LZFu' for compressed data or '.\\x00\\x00\\x00\"\\x00\\x00\\x00MELA' for raw/uncompressed data as expected by the library).","cause":"The input provided to the `decompress` function is not a valid compressed Rich Text Format (RTF) byte string, meaning it lacks the correct headers (like 'LZFu' or 'MELA') or structure, or the data itself is corrupted.","error":"ValueError: Invalid compressed RTF data"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.0.7","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/delimitry/compressed_rtf","docs":null,"changelog":null,"pypi":"https://pypi.org/project/compressed-rtf/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}