You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 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)
*[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
11
50
12
51
This generator can only be used on the server-side and requires a [Node.js](https://nodejs.org/en/download/package-manager/) environment.
13
52
14
-
## Limitations
15
-
16
-
### Shape types
53
+
## Shape Types
17
54
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).
19
56
20
-
###Chart types
57
+
## Chart Types
21
58
22
59
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.
23
60
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
27
62
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.
29
64
30
65
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.
31
66
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
33
72
34
73
All testing focuses on PowerPoint 2019 .pptx file format.
35
74
36
-
## Install
75
+
#Installation
37
76
38
77
There are basically two ways to use `pptx-automizer`.
39
78
40
-
###As a cloned repository
79
+
## As a Cloned Repository
41
80
42
81
If you want to see how it works and you like to run own tests, you should clone this repository and install the dependencies:
43
82
@@ -55,7 +94,7 @@ $ yarn dev
55
94
56
95
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!
57
96
58
-
###As a package
97
+
## As a Package
59
98
60
99
If you are working on an existing project, you can add `pptx-automizer` to it using npm or yarn. Run
61
100
@@ -71,10 +110,14 @@ $ npm install pptx-automizer
71
110
72
111
in the root folder of your project. This will download and install the most recent version into your existing project.
73
112
74
-
## General Example
113
+
#Usage
75
114
76
115
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).
77
116
117
+
## Basic Example
118
+
119
+
This is a basic example on how to use `pptx-automizer` in your code:
`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.
181
224
@@ -301,7 +344,7 @@ If you decide to use the `creationId` method, you are safe to add, remove and re
301
344
302
345
> 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.
303
346
304
-
## Find and modify shapes
347
+
## Find and Modify Shapes
305
348
306
349
There are basically to ways to access a target shape on a slide:
You can select and import generic shapes from any loaded template. It is possible to update the containing text in several ways:
345
388
@@ -389,7 +432,7 @@ Find out more about text replacement:
389
432
-[Replace and style by tags](https://github.com/singerla/pptx-automizer/blob/main/__tests__/replace-tagged-text.test.ts)
390
433
-[Modify text elements using getAllTextElementIds](https://github.com/singerla/pptx-automizer/blob/main/__tests__/get-all-text-element-ids.test.ts)
391
434
392
-
## Modify images
435
+
## Modify Images
393
436
394
437
`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.
395
438
@@ -428,7 +471,7 @@ Find more examples on image manipulation:
-[Modify duotone color overlay for images](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-image-duotone.test.ts)
430
473
431
-
## Modify tables
474
+
## Modify Tables
432
475
433
476
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.
434
477
@@ -457,9 +500,9 @@ Find out more about formatting cells:
457
500
-[Modify and style table cells](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-existing-table.test.ts)
458
501
-[Insert data into table with empty cells](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-existing-table-create-text.test.ts)
459
502
460
-
## Modify charts
503
+
## Modify Charts
461
504
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.
463
506
464
507
```ts
465
508
// Modify an existing chart on an added slide.
@@ -492,7 +535,7 @@ Find out more about modifying charts:
492
535
-[Vertical line charts](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-chart-vertical-lines.test.ts)
493
536
-[Style chart series and data points](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-existing-chart-styled.test.ts)
494
537
495
-
## Modify extended charts
538
+
## Modify Extended Charts
496
539
497
540
If you need to modify extended chart types, such like waterfall or map charts, you need to use `modify.setExtendedChartData`.
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.
542
581
543
582
This is how it works internally:
544
583
@@ -622,6 +661,47 @@ run().catch((error) => {
622
661
});
623
662
```
624
663
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 =awaitpres
670
+
.getTemplate('myTemplate.pptx')
671
+
.getAllSlideNumbers();
672
+
673
+
for (const slideNumber ofslideNumbers) {
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:
0 commit comments