export-ppt
Version:
Export PPTX from template and AI generated text in browser/node.
96 lines (63 loc) • 1.9 kB
Markdown
# export-ppt
Generate PPTX files by combining template JSON with AI-generated text. Works in browser and Node.js.
## Features
- ✅ Simple API: `exportPpt(templateJson, textJson)` → `{ pptUrl: string }`
- ✅ Browser ESM and Node CJS/ESM supported
- ✅ Bundled for browser usage (no extra config)
- ✅ No external dependencies in browser bundle
## Installation
```bash
# npm
npm i export-ppt
# pnpm
pnpm add export-ppt
# yarn
yarn add export-ppt
```
## Usage
### Browser (bundlers or plain ESM)
```ts
import { exportPpt } from 'export-ppt'
const { pptUrl } = await exportPpt(templateJson, textJson)
// Download the PPT
if (pptUrl) {
const a = document.createElement('a')
a.href = pptUrl
a.download = 'presentation.pptx'
a.click()
}
```
### Node.js
```ts
import { exportPpt } from 'export-ppt'
async function run() {
const { pptUrl } = await exportPpt(templateJson, textJson)
console.log('PPT URL:', pptUrl)
}
run()
```
## API
```ts
export declare function exportPpt(
templateJson: string,
textJson: string
): Promise<{ pptUrl: string }>
```
### Parameters
- **templateJson**: Template JSON string containing slide structure and styling
- **textJson**: AI-generated text content JSON string
### Returns
- **pptUrl**: Downloadable URL for the generated PPTX file
## Template JSON Format
Your template JSON should contain slide definitions with objects, styling, and layout information. The library will merge this with the AI-generated text content.
## Text JSON Format
The text JSON should contain structured content that matches your template's expected format, typically generated by AI services.
## Browser Compatibility
- Modern browsers with ES2020+ support
- Works with Vite, Webpack, Rollup, and other bundlers
- No polyfills required
## Node.js Compatibility
- Node.js 16+ (ESM or CommonJS)
- Works with TypeScript out of the box
## License
MIT