Hi team,
I’m working on a PowerPoint Add-in using Office.js (taskpane) and a NestJS backend. The client requirement is to allow users to apply a branded PowerPoint template (master slide + theme) to their existing presentation without replacing the slide content.
Since Office.js doesn’t support applying themes directly (only inserting slides), we are trying a backend workaround using Aspose.Slides Cloud:
Current Approach:
- User uploads their original
.pptxfile from Office.js Add-in taskpane. - They select a saved template (stored in DB & on S3).
- Backend (NestJS) does the following:
- Downloads both the original and template
.pptx. - Uploads them to Aspose Cloud storage (
slides/folder). - Calls
copyMasterSlide()to copy the template’s master slide/theme into the user’s presentation. - Downloads the updated
.pptxand returns back to taskpane.
Code Snippet (NestJS):
const folderName = 'slides';
const originalName = `${folderName}/original-${sessionId}.pptx`;
const templateName = `${folderName}/template-${sessionId}.pptx`;
try {
this.logger.log('Downloading template from S3...');
const templateRes = await fetch(template.pptxUrl);
if (!templateRes.ok) throw new BadRequestException('Failed to download PPTX from S3');
const templateBuffer = Buffer.from(await templateRes.arrayBuffer());
/** ✅ Step 1: Upload both files to Aspose Storage */
this.logger.log('Uploading presentation & template to Aspose Cloud...');
await this.slidesApi.uploadFile(originalName, this.bufferToStream(originalFile.buffer));
await this.slidesApi.uploadFile(templateName, this.bufferToStream(templateBuffer));
/** ✅ Step 2: Copy the Master Slide (Theme) from Template → Presentation */
this.logger.log('Copying master slide from template...');
this.logger.log('templateName, originalName, folderName', templateName, originalName, folderName);
await this.slidesApi.copyMasterSlide(
templateName, // Source file (template)
originalName, // Destination (user's presentation)
1, // Clone master slide index = 1
undefined, // cloneFromPassword
undefined, // cloneFromStorage
true, // applyToAll: apply to all slides
undefined, // password (destination)
folderName, // folder
undefined // storage
);
Issues / Questions:
- Is
copyMasterSlide()the correct method to apply full theme + master layout to all existing slides? - Will this preserve existing slide content while updating design?
- Do we first need to apply master slide, then copy layout slides separately per slide?
- Is there a dedicated method for “Apply template/theme only” instead of inserting new slides?
- Are there any sample Node.js examples for this use case?
- Do template and original need to be in the same folder/storage?
- Any best practices to perform this faster or more reliably?
Thank you! This feature is crucial to match client requirements, so any guidance or sample code would be very helpful.