Officegen-PPTX
Free JavaScript Library for PowerPoint Presentations
A Powerful Open Source JavaScript API to Read, Write, Edit & Convert Microsoft PowerPoint PPTX Presentations.
What is Officegen-PPTX?
Open Source pure JavaScript API that allows computer programmers to generate PowerPoint (PPTX) presentations for Microsoft Office 2007 and later. The great thing about Officegen is that it can work in several environments. It can be used in all those environments that support Node.js including Linux, OSX, and Windows.
Several important features are fully supported by Officegen-PPTX for generating Microsoft PowerPoint documents (.pptx file) such as adding slides, creating native charts, Adding images, hidden slides support, slide layouts support, adding date, time and current slide number, add fonts, colors, and background, etc.
Getting Started with Officegen
The most recent release of officegen can be used by directly installing it from the officegen repository by calling the below command.
Install using officegen repository
$ npm install Ziv-Barber/officegen#master
JavaScript Library to Create PowerPoint PPTX Presentation
Officegen-PPTX API allows developers to create a PowerPoint 2007 presentation inside their own JavaScript applications. It is necessary to create at least one slide in your PPTX or PPSX presentation file. Once the slide is created you can place different objects, such as text box, shapes, images, etc
How to Create PPTX file - JavaScript?
const officegen = require('officegen')
const fs = require('fs')
// Create an empty PPTX file
let pptx = officegen('pptx')
// Add slide
let slide = pptx.makeTitleSlide('FileFormat', 'FileFormat Developer Guide')
// Set output path
let out = fs.createWriteStream('slide.pptx')
// Save
pptx.generate(out)
Add Objects to PPTX Presentation
Officegen-PPTX provides developers the facility to add an image to PowerPoint PPTX Presentation inside JavaScript applications. Once you create a new slide, you can easily add an object to this slide. The object can be a text box, shapes or images, etc. You can easily set properties of objects, such as name, color, show, etc.
How to Add Image in PPTX - JavaScript?
const officegen = require('officegen')
const fs = require('fs')
// Create a new PPTX file
let pptx = officegen('pptx')
// Create a new slide
let slide = pptx.makeNewSlide();
// Add Image
slide.addImage('sample.jpg')
// Set save path
let out = fs.createWriteStream('image.pptx')
// Save
pptx.generate(out)
Add Chart into the PPTX Slide
Software programmers can easily add charts into PowerPoint PPTX Slide using Officegen-PPTX. Developers can use several types of charts inside their JavaScript applications such as column charts, pie charts & bar Chart.
How to Add Chart in Slide - JavaScript?
const officegen = require('officegen')
const fs = require('fs')
// Create a new PPTX file
let pptx = officegen('pptx')
// Create a new slide
let slide = pptx.makeTitleSlide('FileFormat', 'FileFormat Developer Guide')
// Creata a new column chart
slide = pptx.makeNewSlide();
slide.name = 'Chart slide';
slide.back = 'ffffff';
slide.addChart(
{ title: 'Column chart',
renderType: 'column',
valAxisTitle: 'Costs/Revenues ($)',
catAxisTitle: 'Category',
valAxisNumFmt: '$0',
valAxisMaxValue: 24,
data: [ // each item is one serie
{
name: 'Income',
labels: ['2005', '2006', '2007', '2008', '2009'],
values: [23.5, 26.2, 30.1, 29.5, 24.6],
color: 'ff0000' // optional
},
{
name: 'Expense',
labels: ['2005', '2006', '2007', '2008', '2009'],
values: [18.1, 22.8, 23.9, 25.1, 25],
color: '00ff00' // optional
}]
}
)
// Set save path
let out = fs.createWriteStream('Chart.pptx')
// Save
pptx.generate(out)