dazzle-backend-rtf 0.4.6

RTF backend for Dazzle: Document formatting output engine
Documentation

RTF backend for Dazzle document formatting

This crate implements the FotBuilder trait for RTF (Rich Text Format) output, which is used for document formatting and print output.

Purpose

The RTF backend generates formatted documents from DSSSL specifications, supporting:

  • Paragraphs: Text blocks with formatting
  • Character properties: Font, size, weight, posture, color
  • Page setup: Margins, size, headers/footers
  • Document structure: Sections, page sequences
  • Advanced features: Links, tables, lists

Architecture

RtfBackend
  ├─ output: OutputByteStream (RTF file being written)
  ├─ font_table: FontTable (font declarations)
  ├─ color_table: ColorTable (color definitions)
  ├─ document_props: DocumentProperties (page setup, margins)
  └─ flow_stack: Vec<FlowObject> (nested flow object context)

RTF Format Overview

RTF structure:

{\rtf1\ansi\deff0
{\fonttbl...}          # Font table
{\colortbl...}         # Color table
{\stylesheet...}       # Style definitions
\deflang1024           # Document properties
...content...          # Paragraphs and text
}

Usage

use dazzle_backend_rtf::RtfBackend;
use dazzle_core::fot::FotBuilder;
use std::fs::File;

let file = File::create("output.rtf")?;
let mut backend = RtfBackend::new(file)?;

// Start a paragraph
backend.start_paragraph()?;
backend.literal("Hello, world!")?;
backend.end_paragraph()?;

// Finalize and close
backend.finish()?;