Skip to content

[BUG] Shapes without text produce <p:sp> missing <p:txBody>, triggering repair dialog #1441

@NAM-MAN

Description

@NAM-MAN

Description

When a shape is added without text (slideObj.text is undefined or null), genXmlTextBody() returns an empty string. This results in <p:sp> elements without a required <p:txBody> child, which is an OOXML schema violation that triggers the PowerPoint repair dialog.

Root Cause

In gen-xml.ts (compiled: pptxgen.cjs.js around L6120):

if (opts && slideObj._type !== SLIDE_OBJECT_TYPES.tablecell && 
    (typeof slideObj.text === 'undefined' || slideObj.text === null))
    return '';  // ← Returns empty string, so <p:sp> has no <p:txBody>

Per the OOXML spec (ISO/IEC 29500), <p:sp> requires a <p:txBody> child element. PowerPoint repairs the file by adding the missing <p:txBody> elements.

Steps to Reproduce

  1. Add multiple shapes without text (e.g., rectangles used as visual elements)
  2. Generate the .pptx
  3. Open in Microsoft PowerPoint → repair dialog appears
  4. After repair, each shape has <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody> added

Expected Behavior

genXmlTextBody() should return a minimal valid <p:txBody> instead of an empty string:

<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>

Suggested Fix

if (opts && slideObj._type !== SLIDE_OBJECT_TYPES.tablecell && 
    (typeof slideObj.text === 'undefined' || slideObj.text === null))
    return '<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="' + (opts.lang || 'en-US') + '"/></a:p></p:txBody>';

Environment

  • PptxGenJS: 4.0.1
  • PowerPoint for Mac (Microsoft 365)
  • Node.js 22.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions