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
Copy file name to clipboardExpand all lines: README.md
+49-62Lines changed: 49 additions & 62 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# pptx-automizer: A Powerful .pptx Modifier for Node.js
2
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).
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 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
+
If you require to create elements from scratch, `pptx-automizer` wraps around [PptxGenJS](https://github.com/gitbrent/PptxGenJS). Use the powerful syntax of `PptxGenJS` to add dynamic content to your existing .pptx template files. See an example on [how to add a chart from scratch](https://github.com/singerla/pptx-automizer/blob/main/__tests__/generate-pptxgenjs-charts.test.ts).
4
6
5
7
`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
8
@@ -36,6 +38,11 @@ If you require commercial support for complex .pptx automation, you can explore
-[Loop through the slides of a presentation](#loop-through-the-slides-of-a-presentation)
41
48
-[Quickly get all slide numbers of a template](#quickly-get-all-slide-numbers-of-a-template)
@@ -44,10 +51,10 @@ If you require commercial support for complex .pptx automation, you can explore
44
51
-[Import and modify slide Masters](#import-and-modify-slide-masters)
45
52
-[Track status of automation process](#track-status-of-automation-process)
46
53
-[More examples](#more-examples)
47
-
-[Create a new modifier](#create-a-new-modifier)
48
54
-[Troubleshooting](#troubleshooting)
49
55
-[Testing](#testing)
50
56
-[Special Thanks](#special-thanks)
57
+
51
58
<!-- TOC -->
52
59
53
60
# Requirements and Limitations
@@ -174,6 +181,13 @@ const automizer = new Automizer({
174
181
175
182
// use a callback function to track pptx generation process.
176
183
// statusTracker: myStatusTracker,
184
+
185
+
// Use 1 to show warnings or 2 for detailed information
186
+
// 0 disables logging
187
+
verbosity: 1,
188
+
189
+
// Remove all unused placeholders to prevent unwanted overlays:
190
+
cleanupPlaceholders: false
177
191
});
178
192
179
193
// Now we can start and load a pptx template.
@@ -582,6 +596,36 @@ pres
582
596
});
583
597
```
584
598
599
+
## 🔗 Hyperlink Management
600
+
601
+
PowerPoint presentations often use hyperlinks to connect to external websites or internal slides. The PPTX Automizer provides simple and powerful functions to manage hyperlinks in your presentations.
602
+
603
+
### Hyperlink Helper Functions
604
+
605
+
Three core functions are available for all your hyperlink needs:
606
+
607
+
| Function | Description |
608
+
|----------|-------------|
609
+
|`addHyperlink`| Add a new hyperlink to an element |
610
+
611
+
612
+
### Adding Hyperlinks
613
+
614
+
You can add hyperlinks to text elements using the `addHyperlink` helper function. The function accepts either a URL string for external links or a slide number for internal slide links:
The `addHyperlink` function will automatically detect whether the target is an external URL or an internal slide number and set up the appropriate relationship type and attributes.
628
+
585
629
# Tipps and Tricks
586
630
587
631
## Loop through the slides of a presentation
@@ -590,7 +634,7 @@ If you would like to modify elements in a single .pptx file, it is important to
590
634
591
635
This is how it works internally:
592
636
593
-
- Load a root template to append slides to it
637
+
- Load a root template to append slides to
594
638
- (Probably) load root template again to modify slides
595
639
- Load other templates
596
640
- Append a loaded slide to (probably truncated) root template
@@ -622,7 +666,7 @@ const run = async () => {
622
666
// Defining a "name" as second params makes it a little easier
623
667
.load(`SlideWithShapes.pptx`, 'myTemplate');
624
668
625
-
//Get useful information about loaded templates:
669
+
//This is brandnew: get useful information about loaded templates:
@@ -783,10 +827,6 @@ To specify another slideLayout for an added output slide, you need to count slid
783
827
784
828
To add and modify shapes on a slide master, please take a look at [Add and modify shapes](https://github.com/singerla/pptx-automizer#add-and-modify-shapes).
785
829
786
-
If you require to modify slide master backgrounds, please refer to
// Import another slide master and all its slide layouts.
792
832
// Index 1 means, you want to import the first of all masters:
@@ -861,55 +901,6 @@ const automizer = new Automizer({
861
901
});
862
902
```
863
903
864
-
## Create a new modifier
865
-
866
-
If the built-in modifiers of `pptx-automizer` are not sufficient to your task, you can access the target xml elements with [xmldom](https://github.com/xmldom/xmldom). A modifier is a wrapper for such an operation.
867
-
868
-
Let's first take a look at a (simplified) existing modifier: `ModifyTextHelper.content('This is my text')`.
869
-
870
-
```ts
871
-
// "setTextContent" is a function that returns a function.
872
-
// A "label" argument needs to be passed to "setTextContent".
// It is possible to output the xml to console at any time.
889
-
// XmlHelper.dump(element);
890
-
};
891
-
};
892
-
```
893
-
This function will construct an anonymous callback function on setup, while the callback function itself will be executed on runtime, when it's up to the target element on a slide.
894
-
895
-
You can use the modifier e.g. on adding an element:
// Notice: don't call XmlHelper.dump, just pass it
903
-
XmlHelper.dump,
904
-
// 2. Apply modifier from the example above:
905
-
setTextContent('New text'),
906
-
XmlHelper.dump,
907
-
]);
908
-
});
909
-
```
910
-
911
-
We can wrap any xml modification by such a modifier. If you have a working example and you think it will be useful to others, you are very welcome to fork this repo and send a pull request or simply [post it](https://github.com/singerla/pptx-automizer/issues/new).
912
-
913
904
## More examples
914
905
915
906
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, e.g.:
@@ -922,17 +913,13 @@ Take a look into [**tests**-directory](https://github.com/singerla/pptx-automize
If you encounter problems when opening a `.pptx`-file modified by this library, you might worry about PowerPoint not giving any details about the error. It can be hard to find the cause, but there are some things you can check:
927
917
928
918
-**Broken relation**: There are still unsupported shape types and `pptx-automizer` wil not copy required relations of those. You can inflate `.pptx`-output and check `ppt/slides/_rels/slide[#].xml.rels`-files to find possible missing files.
929
919
-**Unsupported media**: You can also take a look at the `ppt/media`-directory of an inflated `.pptx`-file. If you discover any unusual file formats, remove or replace the files by one of the [known types](https://github.com/singerla/pptx-automizer/blob/main/src/enums/content-type-map.ts).
930
920
-**Broken animation**: Pay attention to modified/removed shapes which are part of an animation. In case of doubt, (temporarily) remove all animations from your template. (see [#78](https://github.com/singerla/pptx-automizer/issues/78))
931
921
-**Proprietary/Binary contents** (e.g. ThinkCell): Walk through all slides, slideMasters and slideLayouts and seek for hidden Objects. Hit `ALT+F10` to toggle the sidebar.
932
-
-**Chart styles not working**: If you try to change e.g. color or size of a chart data label, and it doesn't work as expected, try to remove all data labels and activate them again. If this does not help, try to give the first data label of a series a slightly different style (this creates a single data point).
933
-
-**Replace Text not working**: Cut out your e.g. {CustomerName} tag from textbox to clipboard, paste it into a plaintext editor to remove all (visible and invisible) formatting. Copy & paste {CustomerName} back to the textbox. (see [#82](https://github.com/singerla/pptx-automizer/issues/82) and [#73](https://github.com/singerla/pptx-automizer/issues/73))
934
-
-**No related chart worksheet**: It might happen to PowerPoint to lose the worksheet relation for a chart. If a chart gets corrupted by this, you will see a normal chart on your slide, but get an error message if you try to open the datasheet. Please replace the corrupted chart by a working one. (see [#104](https://github.com/singerla/pptx-automizer/issues/104))
935
-
922
+
-**Chart datasheet won't open** If you encounter an error message on opening a chart's datasheet, please make sure that the data table (blue bordered rectangle in worksheet view) of your template starts at cell A:1. If not, open worksheet in Excel mode and edit the table size in the table draft tab.
936
923
937
924
If none of these could help, please don't hesitate to [talk about it](https://github.com/singerla/pptx-automizer/issues/new).
0 commit comments