Create JavaScript PowerPoint Presentations
npm install revent-pptxgen.pptx files directly from their JavaScript code in both client-side and server-side environments.
bash
npm install revent-pptxgen
`
or yarn:
`bash
yarn add revent-pptxgen
`
Usage
Here’s a quick example to get started with creating a PowerPoint presentation:
$3
`javascript
import PptxGenJS from 'revent-pptxgen';
const pptx = new PptxGenJS();
const slide = pptx.addSlide();
// Add Title
slide.addText('Hello Revent PPTXGen!', { x: 1, y: 1, fontSize: 24, color: '363636' });
// Add Image
slide.addImage({ path: 'https://example.com/image.png', x: 0.5, y: 1.5, w: 4, h: 3 });
// Generate and download PPTX
pptx.writeFile('sample-presentation.pptx');
`
$3
`javascript
const PptxGenJS = require('revent-pptgen');
const pptx = new PptxGenJS();
const slide = pptx.addSlide();
slide.addText('Server-side PPTX Generation', { x: 1, y: 1, fontSize: 32 });
// Save to file system
pptx.writeFile('server-side-presentation.pptx').then(() => {
console.log('Presentation created successfully!');
});
`
Development Setup
If you want to work on this library or extend it, clone the repository and install the dependencies:
`bash
git clone https://github.com/ReventAI/revent-pptxgen.git
cd revent-pptxgen
npm install
`
To build the package:
`bash
npm run build
`
This will generate the bundled files in the dist folder.
$3
We also use Gulp for additional build tasks like minification and bundling for demos. The key tasks are:
- gulp build: Builds the core library
- gulp min: Minifies the main bundle
- gulp bundle: Bundles all assets for the demo
- gulp watch`: Watches for changes and rebuilds