Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Node.js OfficeGen Example to Add Text & Images in Powerpoint Presentation in Javascript

Posted on March 10, 2023

 

Welcome folks today in this blog post we will be using the officegen library to generate powerpoint files and adding text and images in node.js and javascript. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make a new node.js project using the below command as shown below

 

 

npm init -y

 

 

npm i officegen

 

 

npm i pptx

 

 

And after that you need to make a new index.js file and copy paste the following code

 

 

index.js

 

 

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const officegen = require('officegen')
const fs = require('fs')
// Create a new PPTX file
let pptx = officegen('pptx')
 
// Add a new slide to the presentation
const slide1 = pptx.makeNewSlide();
 
// Add text to the slide
slide1.addText('Hello, world!');
 
// Create a new slide
let slide2 = pptx.makeNewSlide();
// Add Image
slide2.addImage('image.jpg')
// Set save path
let out = fs.createWriteStream('image.pptx')
// Save
pptx.generate(out)

 

 

As you can see we are importing the xlsx and officegen library at the top and then we are adding a new slide inside the powerpoint file using the makeNewSlide() method. And then we are adding the text using the addText() method and then we are adding the image using the addImage() method. And then we are generating the pptx file using the generate() method.

 

 

 

Recent Posts

  • Node.js OfficeGen Example to Add Text & Images in Powerpoint Presentation in Javascript
  • Node.js OfficeGen Example to Generate Excel Files By Adding Data inside Cells & Sheets in Javascript
  • Node.js OfficeGen Example to Create Word Docx Files & Add Text Images inside it Using Javascript
  • React.js Twitter API Tutorial to Embed Profile & Timeline, Hashtags of User in Browser Using Javascript
  • Android Java Tutorial to Change Styles & Visibility of System Bars (Top, Action & Status) Full Example
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme