Registry / serialization / pyrtf3

pyrtf3

JSON →
library0.47.5pypypiunverified

PyRTF3 is a fork of the original PyRTF library, providing a Pythonic way to generate Rich Text Format (RTF) documents. It allows users to programmatically create complex RTF files including text, paragraphs, sections, tables, lists, and styling. The current version is 0.47.5, with releases occurring periodically to address issues and maintain compatibility.

pip install pyrtf3
INSTALL
IMPORT
SIG · PYRTF3
P
pyrtf3
serializationpythonv0.47.5
Install
1.7s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.47.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.7s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Document
from PyRTF import Document
from PyRTF import Document

This quickstart creates a basic RTF document with two paragraphs of text and saves it to a file named 'simple_pyrtf3_document.rtf'. It demonstrates the core Document, Section, Paragraph, and Text objects.

import os from pyrtf.document import Document, Section, Paragraph, Text def create_simple_rtf(): doc = Document() section = Section() doc.append(section) section.append(Paragraph(Text('Hello, PyRTF3!'))) section.append(Paragraph(Text('This is a simple RTF document generated with Python.'))) output_filename = 'simple_pyrtf3_document.rtf' with open(output_filename, 'wb') as f: doc.write(f) print(f"RTF document '{output_filename}' created successfully.") if __name__ == '__main__': create_simple_rtf()
Debug
Known issues
gotchaThe PyPI package name is `pyrtf3`, but the top-level Python package you import is `pyrtf`. Attempting to `import pyrtf3` or `from pyrtf3 import ...` will result in a `ModuleNotFoundError`.
fix
Always use `import pyrtf` or `from pyrtf.document import ...` for all imports after installing `pyrtf3`.
affects: All pyrtf3 versions (0.x.x)
breakingIf migrating from the original `pyrtf` library (which is no longer maintained), import paths and some API structures have changed significantly. For example, `PyRTF.Document()` becomes `pyrtf.document.Document()`.
fix
Review `pyrtf3` documentation and examples for updated import paths and class structures. Expect to refactor existing `pyrtf` code.
affects: Migration from original pyrtf to pyrtf3
gotchaThe `Document.write()` method requires a binary file-like object (opened with 'wb'), not a string path. Passing a string path or a text file object will cause a `TypeError` or unexpected behavior.
fix
Ensure you open the output file in binary write mode: `with open('filename.rtf', 'wb') as f: doc.write(f)`.
affects: All pyrtf3 versions (0.x.x)
Upgrade
Version history
0.47.5latest on PyPI · released May 19, 2017
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
pyrtf3 — pip install pyrtf3 · libregistry