stamp-pptx
v1.1.0
Published
Stamp: thin pre/post-processing layer on top of dom-to-pptx (upstream 2.1.x) for pixel-perfect HTML-to-PPTX. Adds rgba blending, slide-edge clipping, text wrap guard, wrap=none, background extraction, vertical-center anchoring, gradient text and inner sha
Maintainers
Readme
Stamp (stamp-pptx) v1.0
HTML → editable PPTX. Thin pre/post-processing layer on top of dom-to-pptx (upstream, unmodified).
Bump the dom-to-pptx dependency to pick up upstream features; Stamp only adds what upstream doesn't do.
What Stamp adds (on top of dom-to-pptx 2.1.x)
| Stage | Feature | Why |
|---|---|---|
| pre | rgba() text/background → blended opaque hex | text alpha is unreliable in conversion |
| pre | elements spilling past the slide edge → clip-path: inset() | keeps decorative shapes inside the slide |
| pre | text wrap guard (padding-right buffer + nowrap for single lines) | PPT renders glyphs wider than the browser |
| pre | single-line text → nowrap (+ width buffer) | no re-wrapping when font metrics differ; multi-line boxes keep wrapping |
| post | bottom-most slide-size solid shapes → <p:bg> | real slide background instead of a rectangle |
| post | flex / line-height centred text → anchor="ctr" | vertical centring survives |
| post | background-clip:text gradients → <a:gradFill> in the run | gradient text (upstream: first colour only) |
| post | box-shadow: inset → <a:innerShdw> | upstream ignores inset shadows |
| post | <table> row heights · cell padding · vertical align | upstream writes <a:tr h="0"> |
Everything else — auto font embedding, outer box-shadow, linear-gradient, filter:blur, per-side borders, tables, lists, images, svgAsVector, data-pptx-notes speaker notes, animation classes — comes from upstream.
Usage (browser)
<script src="https://cdn.jsdelivr.net/npm/stamp-pptx@latest/dist/stamp.bundle.js"></script>
<script>
const slides = Array.from(document.querySelectorAll('.s'));
await stamp.exportToPptx(slides, { svgAsVector: true, fileName: 'slides.pptx' });
</script>Options = all dom-to-pptx options plus:
| option | default | |
|---|---|---|
| stampPreProcess | true | rgba blend / edge clip / wrap guard |
| stampPostProcess | true | all XML post-processing |
| stampWrapNone | false | force wrap="none" on every text box (legacy 0.3.0 behaviour) |
| stampTables | true | <table> row heights / cell padding / vertical align from the DOM |
| stampBackground | true | slide-size shape → background |
| stampAnchor | true | centred text → anchor="ctr" |
Font embedding is on by default (upstream autoEmbedFonts). Fonts must be loaded from http(s) URLs with CORS (jsdelivr etc.); file:// fonts cannot be fetched and fall back to system fonts in PowerPoint.
Build
npm install --legacy-peer-deps
npm run build # dist/stamp.mjs, dist/stamp.cjs, dist/stamp.bundle.js