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
- Add multiple shapes without text (e.g., rectangles used as visual elements)
- Generate the .pptx
- Open in Microsoft PowerPoint → repair dialog appears
- 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
Description
When a shape is added without text (
slideObj.textisundefinedornull),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.jsaround L6120):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
<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>addedExpected Behavior
genXmlTextBody()should return a minimal valid<p:txBody>instead of an empty string:Suggested Fix
Environment