Code Monkey home page Code Monkey logo

gitbrent / pptxgenjs Goto Github PK

View Code? Open in Web Editor NEW
2.6K 60.0 611.0 105.29 MB

Create PowerPoint presentations with a powerful, concise JavaScript API.

Home Page: https://gitbrent.github.io/PptxGenJS/

License: MIT License

JavaScript 1.04% TypeScript 97.09% CSS 0.04% HTML 1.82%
powerpoint powerpoint-generation powerpoint-library javascript-powerpoint powerpoint-charts node-powerpoint angular-powerpoint html-to-powerpoint react-powerpoint typescript-powerpoint

pptxgenjs's Introduction

PptxGenJS

Create JavaScript PowerPoint Presentations

PptxGenJS Sample Slides


Known Vulnerabilities npm downloads jsdelivr downloads typescripts definitions

Table of Contents

Introduction

This library creates Open Office XML (OOXML) Presentations which are compatible with Microsoft PowerPoint, Apple Keynote, and other applications.

Features

Works Everywhere

  • Every modern desktop and mobile browser is supported
  • Integrates with Node, Angular, React, and Electron
  • Compatible with PowerPoint, Keynote, and more

Full Featured

  • All major object types are available (charts, shapes, tables, etc.)
  • Master Slides for academic/corporate branding
  • SVG images, animated gifs, YouTube videos, RTL text, and Asian fonts

Simple and Powerful

  • The absolute easiest PowerPoint library to use
  • Learn as you code will full typescript definitions included
  • Tons of demo code comes included (over 75 slides of features)

Export Your Way

  • Exports files direct to client browsers with proper MIME-type
  • Other export formats available: base64, blob, stream, etc.
  • Presentation compression options and more

HTML to PowerPoint

  • Includes powerful HTML-to-PowerPoint feature to transform HTML tables into presentations with a single line of code

Live Demos

Visit the demos page to create a simple presentation to see how easy it is to use pptxgenjs, or check out the complete demo which showcases every available feature.

Installation

Npm

PptxGenJS NPM Home

npm install pptxgenjs --save

Yarn

yarn add pptxgenjs

CDN

jsDelivr Home

Bundle: Modern Browsers and IE11

<script src="https://cdn.jsdelivr.net/gh/gitbrent/[email protected]/dist/pptxgen.bundle.js"></script>

Min files: Modern Browsers

<script src="https://cdn.jsdelivr.net/gh/gitbrent/[email protected]/libs/jszip.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/gitbrent/[email protected]/dist/pptxgen.min.js"></script>

Download

GitHub Latest Release

Bundle: Modern Browsers

  • Use the bundle for IE11 support
<script src="PptxGenJS/dist/pptxgen.bundle.js"></script>

Min files: Modern Browsers

<script src="PptxGenJS/libs/jszip.min.js"></script>
<script src="PptxGenJS/dist/pptxgen.min.js"></script>

Additional Builds

  • CommonJS: dist/pptxgen.cjs.js
  • ES Module: dist/pptxgen.es.js

Documentation

Quick Start Guide

PptxGenJS PowerPoint presentations are created via JavaScript by following 4 basic steps:

Angular/React, ES6, TypeScript

import pptxgen from "pptxgenjs";

// 1. Create a new Presentation
let pres = new pptxgen();

// 2. Add a Slide
let slide = pres.addSlide();

// 3. Add one or more objects (Tables, Shapes, Images, Text and Media) to the Slide
let textboxText = "Hello World from PptxGenJS!";
let textboxOpts = { x: 1, y: 1, color: "363636" };
slide.addText(textboxText, textboxOpts);

// 4. Save the Presentation
pres.writeFile();

Script/Web Browser

// 1. Create a new Presentation
let pres = new PptxGenJS();

// 2. Add a Slide
let slide = pres.addSlide();

// 3. Add one or more objects (Tables, Shapes, Images, Text and Media) to the Slide
let textboxText = "Hello World from PptxGenJS!";
let textboxOpts = { x: 1, y: 1, color: "363636" };
slide.addText(textboxText, textboxOpts);

// 4. Save the Presentation
pres.writeFile();

That's really all there is to it!


Library API

Full documentation and code examples are available


HTML-to-PowerPoint Feature

Easily convert HTML tables to PowerPoint presentations in a single call.

let pptx = new PptxGenJS();
pptx.tableToSlides("tableElementId");
pptx.writeFile({ fileName: "html2pptx-demo.pptx" });

Learn more:


Library Ports

React: react-pptx - thanks to Joonas!


Issues / Suggestions

Please file issues or suggestions on the issues page on github, or even better, submit a pull request. Feedback is always welcome!

When reporting issues, please include a code snippet or a link demonstrating the problem. Here is a small jsFiddle that is already configured and uses the latest PptxGenJS code.


Need Help?

Sometimes implementing a new library can be a difficult task and the slightest mistake will keep something from working. We've all been there!

If you are having issues getting a presentation to generate, check out the code in the demos directory. There are demos for both client browsers, node and react that contain working examples of every available library feature.


Contributors

Thank you to everyone for the issues, contributions and suggestions! ❤️

Special Thanks:

PowerPoint shape definitions and some XML code via Officegen Project


Sponsor Us

If you find this library useful, please consider sponsoring us through a donation


License

Copyright © 2015-present Brent Ely

MIT

pptxgenjs's People

Contributors

ankon avatar bistrostu avatar canwdev avatar clubajax avatar conbow avatar dzmitrydulko avatar gitbrent avatar hilnius avatar hysh avatar iota-pi avatar krishnatejareddyv avatar kyrrigle avatar lhaskin-hbs avatar loictro avatar lucidlemon avatar mariusopeepl avatar mathbruyen avatar mconlin avatar memorsolutions avatar michaelcbrook avatar mikemeerschaert avatar mmarkelov avatar mreilaender avatar ntietz avatar pastafari avatar pdehaan avatar reimafrgos avatar timwatsonruffer avatar tpwingo avatar twatson83 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pptxgenjs's Issues

Multi Page Table - Auto Table creation

Kindly guide me,
I am using below example to create a table with multiple rows.
Expecting Solution : While rows increased dynamically, automatically create new slide if rows crossed the layout. I don't know how to use tabAutoPaging here.

var pptx = new PptxGenJS();
var slide = pptx.addNewSlide();
slide.addText('Demo-03: Table', { x:0.5, y:0.25, font_size:18, font_face:'Arial', color:'0088CC' });

var rows = [
['A1', 'B1', 'C1'],
['A2', 'B2', 'C2']
];
var tabOpts = { x:0.5, y:2.0, w:9.0, fill:'F7F7F7', font_size:18, color:'6f9fc9' };
slide.addTable( rows, tabOpts );

Screenshot attached FYR.
table

Table location and pagination

Greetings! I continue to torment the table :)
At this time I would like to draw your attention to the location of the table when moving to the next slide. The new slide table is moved to the same place where there was a parent.
image

I do not understand how far from the bottom of the slide begins the transfer table. The screenshot shows that the space on the slide is still a lot, but part of the table has been moved to a new slide.
It would be nice if it was possible to disable pagination option.
image
I apologize for these screenshots and my bad english, but the more I can not show.

insert png to existing ppt in browser

hi Brent,

if I have loaded one pptx file template and one png file into browser, how can I insert the png to pptx?

is there a way similar to code below?

var pptx = new PptxGenJS("content of pptx in browser");
var slide = pptx.addNewSlide();
slide.addImage({ data:'image/png;base64,iVtDafDrBF[...]=', x:3.0, y:5.0, w:6.0, h:3.0 });

thanks

add base_64 encoded SVG images

hallo ,

I try to add an SVG Image to a slide with this Code :

slide.addImage({data:"image/svg+xml;base64,PD94bW..... "});

but in the Powerpoint file it didn't show the Image , and display the message : "this picture cannot be displayed"

BUT wenn I remove the "+xml" from the command and will be like this :

slide.addImage({data:"image/svg;base64,PD94bW..... "});

the picture will inserted and displayed !! but this photos displayed just wenn I open the file on my computer , on other Computers it will show the last error message and no photos will showed !!!

Please help me in this issue , if someone know or tried how to add an svg Image .

Best Regards !

HTTP stream

Hi

I've been using officegen module for a while and there you can create a HTTP stream and send the pptx xml in the response by just doing pptx.generate ( response );

Is there any way to do this or similar with PptxGenJS?.

Thanks

Add multiple line text in Table column

Is there a way to add multiple line of text's in columns?

I have a table with 3 columns and 5 rows. One of the column values are like points. (multiple lines)
Ex:
Line one
Line two
...
Line nnn

I need to display as points inside the column, Is there a way to add the multiple line text's inside the column?

Outputs varies for list element

Following are two text elements created in two different ways.

EXAMPLE 1

var pptx = new PptxGenJS();
pptx.setLayout('LAYOUT_WIDE');
var slide = pptx.addNewSlide();

slide.addText(
[
{text: 'Hello', options: { color:'393939', font_size:16 }},
{text: 'Line 1\nLine 2\nLine 3', options: { color:'393939', font_size:16, bullet:true }}
],
{x:2.0, y:1.0, w:'50%', h:1, fill:'F2F2F2'}
);

pptx.save('Demo-Text');
demo 1

EXAMPLE 2

var pptx = new PptxGenJS();
pptx.setLayout('LAYOUT_WIDE');
var slide = pptx.addNewSlide();

slide.addText(
'Hello', { x:2.0, y:1.0, w:'50%', h:1, color:'393939', font_size:16, fill:'F2F2F2' }
);

slide.addText(
'Line 1\nLine 2\nLine 3', { x:2.0, y:2.0, w:'50%', h:1, color:'393939', font_size:16, fill:'F2F2F2', bullet:true }
);

pptx.save('Demo-Text');

demo 2

I want to know why there outputs vary for bullets as per shown in images above, despite the conversion logic is same.

Bullets do not work with text objects in addText() method

I've tried a couple way to make a bullet list - but it's not working as expected:

Test 1:

                     slide2.addText(
                         [
                             {
                                 text: '1st point.'
                             },
                             {
                                 text: 'Something...'
                             }
                         ],
                         {
                             x: 7.75,
                             y: 1.3,
                             w: 2.17,
                             h: 5.5,
                             valign: 'top',
                             margin:0.1,
                             font_face: 'Arial',
                             font_size: 12,
                             bullet: true
                         });

Test 2:

                     slide2.addText(
                         [
                             {
                                 text: '1st point.',
                                 options: {
                                     bullet: true,
                                 }
                             },
                             {
                                 text: 'Something...',
                                 options: {
                                     bullet: true,
                                 }
                             }
                         ],
                         {
                             x: 7.75,
                             y: 1.3,
                             w: 2.17,
                             h: 5.5,
                             valign: 'top',
                             margin:0.1,
                             font_face: 'Arial',
                             font_size: 12,
                             bold: false,
                         });

callback support for save method

I was noticing that I was sending the file before it was update and would like to have a callback fired after the file is written.

Italic option

Any chance you could add italic to the text options?

Trouble running in NW.js

I am trying to run PptcGenJS in a NW.js app. I used npm to installed PptcGenJS in my app/node_modules directory. I am using this code:

var pptxgenjs = require('pptxgenjs');

var pptx = new PptxGenJS();
var slide = pptx.addNewSlide();
slide.addText('Hello World!', { x:1.5, y:1.5, font_size:18, color:'363636' });
pptx.save('Sample Presentation');

I get no result. I'm guessing I'm not calling PptxGenJS correctly

colW can't function

I used the colW property according to document to set each width of column but it failed to work.
There are 7 columns in my table and I set colW like this:

var tabOpts = {x:0.5, y:0.73, cx:9.0, rowH:0.25, colW:[0.65, 3.25, 0.65, 0.65, 0.65, 1.3, 0.65]};

Add ability to create charts

Hi,

I am trying to export the charts to ppt using PptxGenJS. Facing some issues and can you please give idea/suggestion using this plugin.

Thanks in advance

Page Number Y position.

I need to set y positions of Page Numbers.
I am using 'LAYOUT_WIDE' layout for slides.
but when i set isNumbered : true, it is showing page number middle of the slide.
like this:
image

Can you please help me in this.

how to add animations to text

Hello,

Would like to know how i could add animation to text like appear, can someone assist me if possible

regards
Anwar

Support for .mov/.mp4 files

Hey Brent,

Thank you for the support for animated GIFs. They work absolutely fine.

Could you, by any chance, extend or enhance the library to support .mov and/or .mp4 files?

Pagination for slideObj.addTable() ?

I'm absolutely loving this project so far, thanks for the great work!

Is an option for automatic pagination in slideObj.addTable() in the works? This is the one thing that's preventing me from being able to use this project in production.

addImage() - Support for animated GIFs?

Hi,

Thank you for the wonderful project. It is indeed very useful.
Issue: I tried adding a gif image to the ppt, it works fine but the animation doesn't. It gets embedded as an image and not a movie. (just copying a gif into a ppt embeds itself as a movie)

Do you think that feature is already available and I'm doing it wrong or is it something that still needs to be implemented?

Can you try that and let me know if it works?

Thanks.

Formatting rules do not apply to string with '\n'

Formatting rules are ignored after the symbol '\n', e.g:
slide4.addText('first paragraph\nsecond paragraph\nthird paragraph', { x: 0.0, y: '50%', valign: 'middle', align: 'center', color: '000000', font_face: 'Times New Roman', font_size: 16, isTextBox:true});
It looks like:
image

Table formatting bug

Given a table with 7 cols and 2 rows:
image
When I try to bring a table to a form, the value in cell B2 is lost:
image
Now, when I try to connect F1 and F2 rowspan getting corrupted pptx file. Code:
var slide2 = pptx.addNewSlide(); var rows2 = [ [ {text:'A0 and B0', opts:{rowspan:2}},{text:'A1 and A2', opts:{rowspan:2}},{text:'B1 and C1', opts:{colspan:2}},{text:'D1 and E1',opts:{colspan:2}},'F1' ], [ 'B2','C2','D2','E2','F2' ] ]; var tabOpts2 = { x: 0.5, y: 1.5, w: 13, margin:0 }; var celOpts2 = { font_size: 10, font_face: 'Times New Roman', align: 'center', valign: 'middle', border: { pt: '1' } }; slide2.addTable( rows2, tabOpts2, celOpts2 );

Allow select override of Master Slide background color/image

I'd like to set the background color based on a value that is passed from my application. But it doesn't seem possible to pass it through the call to the master slide. Do you have any option for that? I'll need to do the same thing for background images.

Allow more than a single 'x' and/or 'y' table location during Table Paging

Dear brent,

Thank you for the table auto paging.
I am facing one issue, may be you have a solution.

In my slide one heading and description, then my table start from the middle of the slide.
The table automatically creating paging but in the second slide also it is starting from the middle of the slide, same like first slide. Attached the screenshot FYR.

Kindly guide me.

Regards
Jenkins NS
slide

Node module appends to last generated PPT on save()

I'm using the node module in a Sails.js project.

The first time I generate a PPT, everything looks good. When I generate a second PPT, the output file contains both presentations. A third call to .save() will produce a file with all three presentations.

I've tried requiring the module each time my generating method is called instead of a single time at the top of the file, but that's not working.

Is the library caching the last presentation? Is there any way to clear it?

Supported usage via node program instead of HTML

Hello,

I am a nodeJS newbie and I apologize if this is a basic question.

I'm attempting to use PptxGenJS from a simple standalone nodeJS script. I've used NPM to install the pptxgenjs module locally. When I try to import the module into my script, the require keyword returns an empty object.

Here is my code where pptxgenjs is the empty object that is returned.

var pptxgenjs = require ('pptxgenjs');

Is this a supported use of PptxGenJS? I notice the examples are all called from an HTML page.

If so, can anyone help me understand how to import the module into my script?

Thanks,
Travis

cannot read property 'opts' of null

Hello

I have this issue:
image 058

it sometimes can't load the image I put in my local directory.(sometimes it works)
this is my code: pptx.addNewSlide().addImage({x:1.75, y:1.81, w:7.2, h:2.31,path:'datalog/assets/img/KYEC.png'});

Table with 7 columns generates an invalid pptx file.

var pptx = new PptxGenJS();            
var slide = pptx.addNewSlide();
var rows = [1,2,3,4,5,6,7];

slide.addTable(rows);
pptx.save();

For some reason a table with 7 columns generates a pptx which I cannot open. I tried with 1 to 10 columns and only 7 had this problem.

Allow custom Layout sizes (ex: A3)

I would like to see in your wonderful project such new features:

  • A3 layout format
  • images in table cells
  • text multiformatting in single table cells

Table formatting options set to default on empty cells

I have a problem with table options getting defaulted on empty table cells. Consider the following simple code which creates a table:

var pptx = new PptxGenJS();
var slide = pptx.addNewSlide();

var row = [42, 'foo', '', null];
var options = { font_size: 12 };
slide.addTable(row, options);

pptx.save();

I expect that all 4 cells get all the formatting options specified in options. However, the result defaults the styling of the last 2 cells ('' and null). Giving those font size 18.

This might happend for all formatting options. The only other option I was using was font_face which got defaulted to Arial.

load a Template

Hello ,
is it possible to load a pre-prepared Template and used ? for example : a Master Template with logo and colors .

bullets in slides

Hi,

sorry for a newbie question, couldn't find anything in the docs or examples related to this. is there a way to add bullet points to the slide?

nested table issues

Hi,

I have got nested html table. while generating the ppt it is not getting generated. it aways goes into error mode.

please do help me resolve the issues.

Meta: Improve auto-paging in 'addTable()'

addTable() Development Items:

  • New option to disable auto-paging
  • New option to allow a line weight variable so users can adjust paging more precisely
  • Allow use of different x and y values after the initial page

Pingback: This Issue encapsulates Issue #43 and Issue #47 .

Set width and height values in px?

Currently i am trying to export the chart from our app to ppt using PptxGenJS. I am getting px values for all the elements, so how can i set the values (width and height) in px(units) to draw any shapes in PptxGenJS?

If we can't set px in PptxGenJS, do you have any idea that how to convert px to inch/percentage which can be use in PptxGenJS?

Can you please give some suggestion on this. Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.