Skip to content

Commit 6f44f12

Browse files
committed
chore(docs): add functions to readme; add toc
1 parent 48a4d3a commit 6f44f12

File tree

1 file changed

+127
-47
lines changed

1 file changed

+127
-47
lines changed

README.md

Lines changed: 127 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,82 @@
1-
# pptx-automizer: A Powerful PPTX Modifier for Node.js
2-
3-
`pptx-automizer` is a Node.js-based PowerPoint (.pptx) generator that automates the manipulation of existing .pptx files. With pptx-automizer, you can merge templates, customize slide content, and maintain your library of .pptx templates. `pptx-automizer` will not write files from scratch, but edit and merge existing pptx files. You can style template slides within PowerPoint, and these templates will be seamlessly integrated into the output presentation. Most of the content can be modified by using callbacks with [xmldom](https://github.com/xmldom/xmldom).
4-
5-
`pptx-automizer` will fit best to users who try to maintain their own library of pptx template files. This is perfect to anyone who uses complex and well-styled customized layouts. Any existing slide and even a single element can be a data driven template for output pptx files.
6-
7-
This project is accompanied by [automizer-data](https://github.com/singerla/automizer-data). You can use `automizer-data` to import, browse and transform XSLX- or SAV-data into perfectly fitting graph or table data.
8-
Find commercial support for .pptx automation at [ensembl.io](https://ensembl.io).
9-
10-
## Requirements
1+
# pptx-automizer: A Powerful .pptx Modifier for Node.js
2+
3+
`pptx-automizer` is a Node.js-based PowerPoint (.pptx) generator that automates the manipulation of existing .pptx files. With `pptx-automizer`, you can import your library of .pptx templates, merge templates, and customize slide content. `pptx-automizer` will not write files from scratch, but edit and merge existing pptx files. You can style template slides within PowerPoint, and these templates will be seamlessly integrated into the output presentation. Most of the content can be modified by using callbacks with [xmldom](https://github.com/xmldom/xmldom).
4+
5+
`pptx-automizer` is particularly well-suited for users who aim to manage their own library of .pptx template files, making it an ideal choice for those who work with intricate, well-designed customized layouts. With this tool, any existing slide or even a single element can serve as a data-driven template for generating output .pptx files.
6+
7+
This project is accompanied by [automizer-data](https://github.com/singerla/automizer-data). You can use `automizer-data` to import, browse and transform .xlsx- or .sav-data into perfectly fitting graph or table data.
8+
9+
Thanks to all contributors! You are always welcome to share code, tipps and ideas. We appreciate all levels of expertise and encourage everyone to get involved. Whether you're a seasoned pro or just starting out, your contributions are invaluable. [Get started](https://github.com/singerla/pptx-automizer/issues/new)
10+
11+
If you require commercial support for complex .pptx automation, you can explore [ensemblio.com](https://ensemblio.com). Ensemblio is a web application that leverages `pptx-automizer` and `automizer-data` to provide an accessible and convenient solution for automating .pptx files. Engaging with Ensemblio is likely to enhance and further develop this library.
12+
13+
## Table of contents
14+
<!-- TOC -->
15+
* [Requirements and Limitations](#requirements-and-limitations)
16+
* [Shape Types](#shape-types)
17+
* [Chart Types](#chart-types)
18+
* [Slide Masters and -Layouts](#slide-masters-and--layouts)
19+
* [Direct Manipulation of Elements](#direct-manipulation-of-elements)
20+
* [PowerPoint Version](#powerpoint-version)
21+
* [Installation](#installation)
22+
* [As a Cloned Repository](#as-a-cloned-repository)
23+
* [As a Package](#as-a-package)
24+
* [Usage](#usage)
25+
* [Basic Example](#basic-example)
26+
* [How to Select Slides Shapes](#how-to-select-slides-shapes)
27+
* [Select slide by number and shape by name](#select-slide-by-number-and-shape-by-name)
28+
* [Select slides by creationId](#select-slides-by-creationid)
29+
* [Find and Modify Shapes](#find-and-modify-shapes)
30+
* [Modify Text](#modify-text)
31+
* [Modify Images](#modify-images)
32+
* [Modify Tables](#modify-tables)
33+
* [Modify Charts](#modify-charts)
34+
* [Modify Extended Charts](#modify-extended-charts)
35+
* [Remove elements from a slide](#remove-elements-from-a-slide)
36+
* [Tipps and Tricks](#tipps-and-tricks)
37+
* [Loop through the slides of a presentation](#loop-through-the-slides-of-a-presentation)
38+
* [Quickly get all slide numbers of a template](#quickly-get-all-slide-numbers-of-a-template)
39+
* [Find all text elements on a slide](#find-all-text-elements-on-a-slide)
40+
* [Sort output slides](#sort-output-slides)
41+
* [Import and modify slide Masters](#import-and-modify-slide-masters)
42+
* [Track status of automation process](#track-status-of-automation-process)
43+
* [More examples](#more-examples)
44+
* [Testing](#testing)
45+
* [Special Thanks](#special-thanks)
46+
* [Commercial Support](#commercial-support)
47+
<!-- TOC -->
48+
49+
# Requirements and Limitations
1150

1251
This generator can only be used on the server-side and requires a [Node.js](https://nodejs.org/en/download/package-manager/) environment.
1352

14-
## Limitations
15-
16-
### Shape types
53+
## Shape Types
1754

18-
At the moment, you might encounter difficulties for special shape types that require further relations (e.g. links will not work properly). Although, most shape types are already supported, such as connection shapes, tables or charts. You are welcome to [report any issue](https://github.com/singerla/pptx-automizer/issues/new).
55+
At the moment, you might encounter difficulties with special shape types that require additional relations (e.g., hyperlinks, video and audio may not work correctly). However, most shape types, including connection shapes, tables, and charts, are already supported. If you encounter any issues, please feel free to [report any issue](https://github.com/singerla/pptx-automizer/issues/new).
1956

20-
### Chart types
57+
## Chart Types
2158

2259
Extended chart types, like waterfall or map charts, are basically supported. You might need additional modifiers to handle extended properties, which are not implemented yet. Please help to improve `pptx-automizer` and [report](https://github.com/singerla/pptx-automizer/issues/new) issues regarding extended charts.
2360

24-
### Slide Masters and -Layouts
25-
26-
`pptx-automizer` supports importing slide masters and their associated slide layouts into the output presentation.
61+
## Slide Masters and -Layouts
2762

28-
While `pptx-automizer` allows you to import and work with slide layouts, it's important to note that you cannot add, modify, or remove individual slideLayouts directly. However, you have the flexibility to modify the underlying slideMaster, which can serve as a workaround for certain changes.
63+
`pptx-automizer` supports importing slide masters and their associated slide layouts into the output presentation. It is important to note that you cannot add, modify, or remove individual slideLayouts directly. However, you have the flexibility to modify the underlying slideMaster, which can serve as a workaround for certain changes.
2964

3065
Please be aware that importing slideLayouts containing complex contents, such as charts and images, is currently not supported. For instance, if a slideLayout includes an icon that is not present on the slideMaster, this icon will break when the slideMaster is auto-imported into an output presentation. To avoid this issue, ensure that all images and charts are placed exclusively on a slideMaster and not on a slideLayout.
3166

32-
### PowerPoint Version
67+
## Direct Manipulation of Elements
68+
69+
It is also important to know that `pptx-automizer` is currently limited to _adding_ things to the output presentation. If you require the ability to, for instance, modify a specific element on a slide within an existing presentation and leave the rest untouched, you will need to include all the other slides in the process. Find some workarounds [below](#loop-through-the-slides-of-a-presentation).
70+
71+
## PowerPoint Version
3372

3473
All testing focuses on PowerPoint 2019 .pptx file format.
3574

36-
## Install
75+
# Installation
3776

3877
There are basically two ways to use `pptx-automizer`.
3978

40-
### As a cloned repository
79+
## As a Cloned Repository
4180

4281
If you want to see how it works and you like to run own tests, you should clone this repository and install the dependencies:
4382

@@ -55,7 +94,7 @@ $ yarn dev
5594

5695
and see the most recent feature from `src/dev.ts`. Every time you change & save this file, you will see new console output and a pptx file in the destination folder. Take a look into `__tests__`-directory to see a lot of examples for several use cases!
5796

58-
### As a package
97+
## As a Package
5998

6099
If you are working on an existing project, you can add `pptx-automizer` to it using npm or yarn. Run
61100

@@ -71,10 +110,14 @@ $ npm install pptx-automizer
71110

72111
in the root folder of your project. This will download and install the most recent version into your existing project.
73112

74-
## General Example
113+
# Usage
75114

76115
Take a look into [**tests**-directory](https://github.com/singerla/pptx-automizer/blob/main/__tests__) to see a lot of examples for several use cases. You will also find example .pptx-files there. Most of the examples shown below make use of [those files](https://github.com/singerla/pptx-automizer/blob/main/__tests__/pptx-templates).
77116

117+
## Basic Example
118+
119+
This is a basic example on how to use `pptx-automizer` in your code:
120+
78121
```ts
79122
import Automizer from 'pptx-automizer';
80123

@@ -143,7 +186,7 @@ const presInfo = await pres.getInfo();
143186
const mySlides = presInfo.slidesByTemplate('shapes');
144187
const mySlide = presInfo.slideByNumber('shapes', 2);
145188
const myShape = presInfo.elementByName('shapes', 2, 'Cloud');
146-
*/
189+
*/
147190

148191
// addSlide takes two arguments: The first will specify the source
149192
// presentation's label to get the template from, the second will set the
@@ -175,7 +218,7 @@ const finalJSZip = await pres.getJSZip();
175218
const base64 = await finalJSZip.generateAsync({ type: 'base64' });
176219
```
177220

178-
## How to select target slide and shapes
221+
## How to Select Slides Shapes
179222

180223
`pptx-automizer` needs a selector to find the required shape on a template slide. While an imported .pptx file is identified by filename or custom label, there are different ways to address its slides and shapes.
181224

@@ -301,7 +344,7 @@ If you decide to use the `creationId` method, you are safe to add, remove and re
301344

302345
> Please note: PowerPoint is going to update a shape's `creationId` only in case the shape was copied & pasted on a slide with an already existing identical shape `creationId`. If you were copying a slide, each shape `creationId` will be copied, too. As a result, you have unique shape ids, but different slide `creationIds`. If you are now going to paste a shape an such a slide, a new creationId will be given to the pasted shape. As a result, slide ids are unique throughout a presentation, but shape ids are unique only on one slide.
303346
304-
## Find and modify shapes
347+
## Find and Modify Shapes
305348

306349
There are basically to ways to access a target shape on a slide:
307350

@@ -339,7 +382,7 @@ pres.addSlide('shapes', 1, (slide) => {
339382
});
340383
```
341384

342-
## Modify text
385+
## Modify Text
343386

344387
You can select and import generic shapes from any loaded template. It is possible to update the containing text in several ways:
345388

@@ -389,7 +432,7 @@ Find out more about text replacement:
389432
- [Replace and style by tags](https://github.com/singerla/pptx-automizer/blob/main/__tests__/replace-tagged-text.test.ts)
390433
- [Modify text elements using getAllTextElementIds](https://github.com/singerla/pptx-automizer/blob/main/__tests__/get-all-text-element-ids.test.ts)
391434

392-
## Modify images
435+
## Modify Images
393436

394437
`pptx-automizer` can extract images from loaded .pptx template files and add to your output presentation. You can use shape modifiers (e.g. for size and position) on images, too. Additionally, it is possible to load external media files directly and update relation `Target` of an existing image. This works on both, existing or added images.
395438

@@ -428,7 +471,7 @@ Find more examples on image manipulation:
428471
- [Add external image](https://github.com/singerla/pptx-automizer/blob/main/__tests__/add-external-image.test.ts)
429472
- [Modify duotone color overlay for images](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-image-duotone.test.ts)
430473

431-
## Modify tables
474+
## Modify Tables
432475

433476
You can use a PowerPoint table and add/modify data and style. It is also possible to add rows and columns and to style cells.
434477

@@ -457,9 +500,9 @@ Find out more about formatting cells:
457500
- [Modify and style table cells](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-existing-table.test.ts)
458501
- [Insert data into table with empty cells](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-existing-table-create-text.test.ts)
459502

460-
## Modify charts
503+
## Modify Charts
461504

462-
All data and styles of a chart can be modified. Please notice: If your template has more data than your data object, automizer will remove these nodes. Vice versa, new nodes will be cloned from the first existing one in case you provide more data.
505+
All data and styles of a chart can be modified. Please note that if your template contains more data than your data object, Automizer will remove these extra nodes. Conversely, if you provide more data, new nodes will be cloned from the first existing one in the template.
463506

464507
```ts
465508
// Modify an existing chart on an added slide.
@@ -492,7 +535,7 @@ Find out more about modifying charts:
492535
- [Vertical line charts](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-chart-vertical-lines.test.ts)
493536
- [Style chart series and data points](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-existing-chart-styled.test.ts)
494537

495-
## Modify extended charts
538+
## Modify Extended Charts
496539

497540
If you need to modify extended chart types, such like waterfall or map charts, you need to use `modify.setExtendedChartData`.
498541

@@ -504,13 +547,9 @@ pres.addSlide('charts', 2, (slide) => {
504547
series: [{ label: 'series 1' }],
505548
categories: [
506549
{ label: 'cat 2-1', values: [100] },
507-
{ label: 'cat 2-2', values: [20] },
508550
{ label: 'cat 2-3', values: [50] },
509551
{ label: 'cat 2-4', values: [-40] },
510-
{ label: 'cat 2-5', values: [130] },
511-
{ label: 'cat 2-6', values: [-60] },
512-
{ label: 'cat 2-7', values: [70] },
513-
{ label: 'cat 2-8', values: [140] },
552+
// ...
514553
],
515554
}),
516555
]);
@@ -534,11 +573,11 @@ pres
534573
});
535574
```
536575

537-
# Examples
576+
# Tipps and Tricks
538577

539-
## Loop through an existing presentation
578+
## Loop through the slides of a presentation
540579

541-
If you would like to modify some elements in a single .pptx file, it is important to that `pptx-automizer` is not able to directly "jump" to a shape and modify.
580+
If you would like to modify elements in a single .pptx file, it is important to know that `pptx-automizer` is not able to directly "jump" to a shape to modify it.
542581

543582
This is how it works internally:
544583

@@ -622,6 +661,47 @@ run().catch((error) => {
622661
});
623662
```
624663

664+
## Quickly get all slide numbers of a template
665+
666+
When calling `pres.getInfo()`, it will gather information about all elements on all slides of all templates. In case you just want to loop through all slides of a certain template, you can use this shortcut:
667+
668+
```ts
669+
const slideNumbers = await pres
670+
.getTemplate('myTemplate.pptx')
671+
.getAllSlideNumbers();
672+
673+
for (const slideNumber of slideNumbers) {
674+
// do the thing
675+
}
676+
```
677+
678+
## Find all text elements on a slide
679+
680+
When processing an added slide, you might want to apply a modifier to any existing text element. Call `slide.getAllTextElementIds()` for this:
681+
682+
```ts
683+
import Automizer, { modify } from 'pptx-automizer';
684+
685+
pres.addSlide('myTemplate.pptx', 1, async (slide) => {
686+
const elements = await slide.getAllTextElementIds();
687+
elements.forEach((element) => {
688+
// element has a text body:
689+
slide.modifyElement(element, [modify.setText('my text')]);
690+
// ... or use the tag replace function:
691+
slide.modifyElement(element, [
692+
modify.replaceText([
693+
{
694+
replace: 'TAG',
695+
by: {
696+
text: 'my tag text',
697+
},
698+
},
699+
]),
700+
]);
701+
});
702+
});
703+
```
704+
625705
## Sort output slides
626706

627707
There are three ways to arrange slides in an output presentation.
@@ -779,7 +859,7 @@ Take a look into [**tests**-directory](https://github.com/singerla/pptx-automize
779859
- [Update chart plot area coordinates](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-chart-plot-area.test.ts)
780860
- [Update chart legend](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-chart-legend.test.ts)
781861

782-
### Testing
862+
## Testing
783863

784864
You can run all unit tests using these commands:
785865

@@ -788,16 +868,16 @@ yarn test
788868
yarn test-coverage
789869
```
790870

791-
### Special Thanks
871+
# Special Thanks
792872

793-
This project is deeply inspired by:
873+
This project was inspired by:
794874

795875
- [PptxGenJS](https://github.com/gitbrent/PptxGenJS)
796876
- [officegen](https://github.com/Ziv-Barber/officegen)
797877
- [node-pptx](https://github.com/heavysixer/node-pptx)
798878
- [docxtemplater](https://github.com/open-xml-templating/docxtemplater)
799879

800-
### Commercial Support
880+
# Commercial Support
801881

802-
If you need commercial support on complex .pptx automation, please take a look at [ensembl.io](https://ensembl.io).
803-
![ensemblio](https://ensembl.io/ensemblio-lg.png)
882+
If you need commercial support on complex .pptx automation, please take a look at [ensemblio.com](https://ensemblio.com).
883+
![ensemblio](https://ensemblio.com/ensemblio-lg.png)

0 commit comments

Comments
 (0)