Understand the dom-to-pptx architecture and data flow
masterThe dom-to-pptx ecosystem follows a layered pipeline architecture that transforms web content into PowerPoint presentations.
1. Input Layer
Consumes the DOM Tree (via elements, selectors, or arrays), CSS (computed and external styles), and user-provided Export Options (dimensions, scale, fonts, etc.).
2. Core Engine (src/index.js)
exportToPptx(): The primary entry point for all exports.processSlide(): The traversal engine that walks the DOM.prepareRenderItem(): An item factory that converts DOM nodes into renderable objects.RenderQueue: Manages both synchronous and asynchronous tasks to feed data intoPptxGenJS.
3. Analysis & Layout (src/utils.js)
Handles the heavy lifting of DOM inspection, including:
- Text Parsing:
collectTextParts()extracts rich text;isTextContainer()identifies text nodes. - Layout:
getPadding()and margin creation functions. - Styling:
parseColor()for RGB/Alpha conversion andFontDetectionfor resolving CSS font faces. - Metadata:
extractSpeakerNotesFromElement()for presentation notes.
4. Font Embedding Pipeline (src/font-embedder.js)
Detects fonts via getAutoDetectedFonts(), classifies variants, and uses a Wasm/opentype.js converter to transform fonts into EOT format for injection into the PPTX archive.
5. Post-Processing Normalizer (src/pptx-normalizer.js)
Uses JSZip to decompress the generated archive and applies critical patches:
ZReorder: Sorts shape Z-indices (<p:sp>).AnimInject: Injects the<p:timing>animation tree.TransInject: Injects slide transitions.ContentTypeScrubber: Removes dangling<Override>tags to ensure file validity.