dom-to-pptx - npm explorer



Analysis Summary


The
Q3 projection
exceeds expectations due to the new
optimization algorithm. We observed a
240% increase
in processing speed across all nodes.




class="absolute bottom-6 right-6 bg-white/90 backdrop-blur px-4 py-2 rounded-lg shadow-lg border border-slate-200 flex items-center gap-2"
>

Confidential



`

API

$3

Returns: Promise - Resolves with the generated PPTX file data (Blob).

| Parameter | Type | Description |
| :------------------ | :---------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------- |
|
elementOrSelector | string \| HTMLElement \| Array | The DOM node(s) or ID selector(s) to convert. Can be a single element/selector or an array for multi-slide export. |
|
options | object | Configuration object. |

Options Object:

| Key | Type | Default | Description |
| :--------------- | :-------- | :-------------- | :------------------------------------------------------------------------------------------------------------ |
|
fileName | string | "export.pptx" | The name of the downloaded file. |
|
autoEmbedFonts | boolean | true | Automatically detect and embed used fonts. |
|
fonts | Array | [] | Manual array of font objects: { name, url }. |
|
skipDownload | boolean | false | If true, the file is not downloaded automatically. Use the returned Blob for custom handling (upload). |
|
svgAsVector | boolean | false | If true, keeps SVG elements as vectors (not rasterized). Enables "Convert to Shape" in PowerPoint. |
|
listConfig | object | undefined | Global overrides for list styles. Structure: { color: string, spacing: { before: number, after: number } }. |

List Configuration Example:

`javascript
listConfig: {
spacing: {
before: 10, // Space before bullet (pt)
after: 5 // Space after bullet (pt)
}
}
`

Important Notes

1. Fonts & CORS:
- Automatic Embedding: Works perfectly for local fonts and external fonts served with correct CORS headers.
- Google Fonts: For auto-detection to work with Google Fonts, you must add
crossorigin="anonymous" to your link tag:

- If a font cannot be accessed due to CORS, the library will log a warning and proceed without embedding it (PowerPoint will fallback to Arial).

2. Layout System: The library does not "read" Flexbox or Grid definitions directly. It measures the final x, y, width, height of every element relative to the slide root and places them absolutely. This ensures 100% visual accuracy regardless of the CSS layout method used.

3. CORS Images: External images ( tags) must also be served with Access-Control-Allow-Origin: * headers to be processed by the rounding/masking engine.

License

MIT © Atharva Dharmendra Jagtap and dom-to-pptx` contributors.

Acknowledgements

This project is built on top of PptxGenJS. Huge thanks to the PptxGenJS maintainers and all contributors — dom-to-pptx leverages and extends their excellent work on PPTX generation.