-
Notifications
You must be signed in to change notification settings - Fork 0
/
pptxtemplater.js
27 lines (20 loc) · 954 Bytes
/
pptxtemplater.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const fs = require('fs');
const officegen = require('officegen');
const Docxtemplater = require('docxtemplater');
// Create a new PowerPoint presentation (main presentation) using officegen
const mainPresentation = officegen('pptx');
// Load the source (template) presentation using officegen
const sourcePresentation = officegen('pptx');
sourcePresentation.load('path/to/source_presentation.pptx');
// Define the output file name for the main presentation
const outputFileName = 'path/to/output_presentation.pptx';
// Create a writable stream to save the main presentation
const outputStream = fs.createWriteStream(outputFileName);
// Pipe the source presentation to the main presentation
sourcePresentation.generate(outputStream);
outputStream.on('finish', () => {
console.log('Main presentation with copied slides saved successfully.');
});
outputStream.on('error', (error) => {
console.error('Error saving main presentation:', error);
});