Skip to content

PPTX: shapes with text discard fill color (TextBox vs Shape branch) #103

@developer0hye

Description

@developer0hye

Description

When a PPTX shape has both a solid fill (or gradient) AND text content, the parser emits it as a TextBox and discards the fill color, stroke, rotation, opacity, and shadow. This causes shapes with background colors and text to lose their background.

Root Cause

In crates/office2pdf/src/parser/pptx.rs (line ~2068-2111), the shape finalization logic is:

let has_text = paragraphs.iter().any(|p| !p.runs.is_empty());

if has_text {
    // TextBox — only text content, fill/stroke/etc. discarded
    kind: FixedElementKind::TextBox(blocks),
} else if let Some(ref geom) = prst_geom {
    // Shape — fill, stroke, rotation preserved
    kind: FixedElementKind::Shape(Shape { fill: shape_fill, ... }),
}

The TextBox branch does not carry any shape properties. So a rectangle with solidFill="#003366" and text "Section Title" inside it will render as plain text with no background.

Expected

A colored rectangle with text overlaid on it.

Actual

Only the text is rendered, with no background shape.

Fix Suggestion

Either:

  1. Extend FixedElementKind::TextBox to carry optional shape properties (fill, stroke, etc.), or
  2. Emit both a Shape element and a TextBox element at the same position when a shape has both fill and text

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions