Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
97e4ab9
feature(use): add pptxgen to deps; basic implementation #60
singerla Oct 26, 2023
7cfbbf2
feature(use): add image from scratch #60 #62
singerla Oct 26, 2023
923e3f9
feature(use): add pptxgen to deps; basic implementation #60
singerla Oct 26, 2023
be2b281
feature(generate): use pptxgenjs to insert elements from scratch (WIP)
singerla Nov 24, 2023
4851f30
Merge remote-tracking branch 'origin/feature-use-pptxgenjs' into feat…
singerla Nov 24, 2023
122b7fc
test(generate): text, charts, images with pptxgenjs #60
singerla Nov 27, 2023
395a62b
feature(use): add pptxgen to deps; basic implementation #60
singerla Oct 26, 2023
81bba51
feature(generate): use pptxgenjs to insert elements from scratch (WIP)
singerla Nov 24, 2023
adfe37f
feature(use): add pptxgen to deps; basic implementation #60
singerla Oct 26, 2023
1baa407
feature(use): add image from scratch #60 #62
singerla Oct 26, 2023
fe3421e
test(generate): text, charts, images with pptxgenjs #60
singerla Nov 27, 2023
b2e63c6
chore(test): update dev & lock file
singerla Feb 6, 2024
e45099e
Merge remote-tracking branch 'origin/feature-use-pptxgenjs' into feat…
singerla Feb 6, 2024
a675ebf
chore(shape): throw error if source element undefined
singerla May 31, 2024
a606c56
chore(xml): add normalizeColorObject
singerla Jul 19, 2024
2bb2210
updated .load, .loadRoot, rootTemplate and preTemplates to allow for …
mikemeerschaert Jul 26, 2024
d19397b
chore(test): fetch pptx template from url
singerla Jul 29, 2024
12049dd
chore(doc): add files from buffer/url to readme
singerla Jul 29, 2024
7ec20a0
Merge pull request #109
singerla Jul 29, 2024
5d0ed9b
chore(lib): add yarn info to package
singerla Jul 29, 2024
9d22353
v0.5.0
singerla Jul 29, 2024
f248ff5
chore(test): add a demo reader for table cells
singerla Jul 29, 2024
be7e7d2
Merge pull request #111
mikemeerschaert Jul 31, 2024
a9e5ec4
chore(test): add example for #113
singerla Aug 2, 2024
b4696ca
Merge remote-tracking branch 'origin/main'
singerla Aug 2, 2024
6d1588f
fix(table): add test for table cell without <a:p> #112
singerla Aug 2, 2024
bcf90c5
fix(table): create para props parent if not existing; fixes #112; fix…
singerla Aug 5, 2024
06b2f34
feat(table): support for nested tables
singerla Aug 5, 2024
9ea96c0
feat(read): read chart series color; #115
singerla Aug 6, 2024
7521c76
feat(read): read shape info / copy shape coordinates; #114
singerla Aug 6, 2024
a3d46a5
test(read): cross-slide copy shape properties
singerla Aug 6, 2024
dc62b7d
chore(doc): add get shape info to readme toc
singerla Aug 6, 2024
07ce202
chore(doc): fix typo in readme
singerla Aug 6, 2024
b30be53
Merge remote-tracking branch 'origin/main' into feature-nested-table
singerla Aug 6, 2024
cf7013e
feat(table): clone nested gridCols
singerla Aug 6, 2024
2674573
Add AltText to Element Info
jrking4 Aug 6, 2024
58b5f0d
Add Alt Text test
jrking4 Aug 6, 2024
861e328
feat(table): use tags to expand rows or (nested) columns
singerla Aug 7, 2024
ea0f4bd
Merge remote-tracking branch 'origin/main' into fork/jrking4/main
singerla Aug 7, 2024
fab9d43
Merge pull request #116
jrking4 Aug 7, 2024
8dec8b8
chore(image): use a function for altText
singerla Aug 7, 2024
45c5e50
Merge remote-tracking branch 'origin/main'
singerla Aug 7, 2024
0fa0db1
chore(image): use a function for altText
singerla Aug 7, 2024
7e6df11
chore(shape): disable table reader
singerla Aug 7, 2024
3b9d854
chore(read): move table data reader to slide-helper
singerla Aug 8, 2024
ea65232
chore(xml): disable falsy errors on missing relations
singerla Aug 8, 2024
b0d1f9b
chore(doc): add expand table to readme
singerla Aug 8, 2024
4ae2c33
v0.5.1
singerla Aug 8, 2024
ac9ac33
fix(table): insert more than one expand column
singerla Aug 9, 2024
daee588
chore(table): WIP improve table cell cloning / expansion
singerla Aug 13, 2024
57fd995
feat(table): update column/row size by index
singerla Sep 9, 2024
41b31bf
fix(table): remove all remaining text after inserting text into a tab…
singerla Sep 11, 2024
a6e3903
add ability to create indented lists
jrking4 Sep 13, 2024
05e019b
Merge branch 'singerla:main' into main
jrking4 Sep 13, 2024
d0ec22b
refactor to utility functions
jrking4 Sep 15, 2024
0d5c402
additional cleanup
jrking4 Sep 16, 2024
754af40
Merge pull request #119
singerla Sep 16, 2024
4743727
chore(docs): troubleshooting replace text
singerla Sep 16, 2024
e0c720f
v0.5.2
singerla Sep 16, 2024
f06cdf0
make bullet replacement less destructive.
jrking4 Sep 16, 2024
0ccb423
Merge branch 'singerla:main' into main
jrking4 Sep 16, 2024
2f9c535
remove debug
jrking4 Sep 16, 2024
3d29c1d
Merge branch 'main' of https://github.com/jrking4/pptx-automizer
jrking4 Sep 16, 2024
0887d73
Merge pull request #120
singerla Sep 19, 2024
0dd27e0
fix: upgrade @xmldom/xmldom from 0.8.10 to 0.9.1
snyk-bot Sep 26, 2024
05071a8
Merge pull request #122 from singerla/snyk-upgrade-5ccf9e74d77f9bccba…
singerla Oct 7, 2024
6fc61cd
chore: add "dom" to lib
singerla Oct 16, 2024
4c09692
Merge remote-tracking branch 'origin/main'
singerla Oct 16, 2024
5451192
fix(types): upgraded xmldom version
singerla Oct 16, 2024
c772f40
feat: ✨ add OLE support
MP70 Oct 23, 2024
b456f34
fix: multiple OLEs, same ext type, same slide.
MP70 Oct 24, 2024
4bcbdf2
🐛 Fix #124
MP70 Oct 25, 2024
60ec79a
Merge pull request #127 from singerla/mp70_feat_OLEsupport
singerla Oct 31, 2024
ab193f9
chore: apply prettier rules to ole.ts
singerla Nov 5, 2024
d964d73
fix(file): use proper file.name on cleaning up media dir; fixes #128
singerla Nov 5, 2024
866ec77
chore(test): replace (tagged) bulleted text
singerla Nov 6, 2024
7927a00
fix: upgrade @xmldom/xmldom from 0.9.3 to 0.9.4
snyk-bot Nov 9, 2024
174c949
fix(chart): update chart image rels properly; fixes #128
singerla Nov 11, 2024
ee31549
test(chart): todo: cleanup unused edgy images; #128
singerla Nov 11, 2024
78d7cc1
Merge remote-tracking branch 'origin/feature-use-pptxgenjs'
singerla Nov 11, 2024
bed4849
Merge pull request #129 from singerla/snyk-upgrade-5376426820bc42b44c…
singerla Nov 11, 2024
7ceda09
Merge remote-tracking branch 'origin/main'
singerla Nov 11, 2024
bce71f1
chore: remove package-lock
singerla Nov 11, 2024
3d5514c
chore: update yarn.lock
singerla Nov 11, 2024
f7a2d80
chore(test): fix template and dir names
singerla Nov 11, 2024
5e8d059
fix(table): skip table cells without 'a:txBody' to prevent error with…
singerla Nov 25, 2024
f5d7756
chore(ole): remove modify and append for OLE objects
singerla Nov 25, 2024
5a169e0
fix(table): exclude tcPr; fix mimeType for DOMParser
singerla Nov 25, 2024
cd9415c
chore(test): google slides created tables with merged cells
singerla Nov 25, 2024
6a0ab36
v0.6.0
singerla Nov 25, 2024
7d9329f
chore(deps): bump cross-spawn from 7.0.3 to 7.0.6
dependabot[bot] Nov 25, 2024
5a6b406
fix(table): always use first row as template for new rows; see #63
singerla Dec 6, 2024
70a9ff2
chore(doc): troubleshooting chart data
singerla Dec 9, 2024
b62300f
fix(image): slugify external image name to prevent issues with specia…
singerla Dec 11, 2024
5f860c1
test(image): add test image with special characters in filename
singerla Dec 11, 2024
4d6c1ea
chore(shape): replace/remove shape placeholders properly
singerla Dec 12, 2024
7eb8809
fix(table): do not expand cells in default table
singerla Dec 13, 2024
3bf517c
feat(chart): modifiy cahrt series datalabel solidFill color
singerla Dec 18, 2024
8ec1647
feat(chart): directly use ChartDataLabelAttributes with chart series …
singerla Dec 18, 2024
c18cf9b
feat(log): configurable logging verbosity; fixes #134
singerla Dec 18, 2024
3b108fd
test(shape): add pptx to test smartart
singerla Dec 18, 2024
f73f0cc
v0.6.1
singerla Dec 19, 2024
9185ee7
fix: make cleanupPlaceholders optional; seek closest parent; fixes #139
singerla Dec 20, 2024
841b33c
v0.6.2
singerla Dec 20, 2024
f4ec662
chore(chart): read chart type; #140
singerla Dec 25, 2024
42539b6
fix: upgrade @xmldom/xmldom from 0.9.5 to 0.9.6
snyk-bot Dec 27, 2024
d6f40b4
fix(image): handle svg images properly
singerla Jan 8, 2025
6859770
feat(generate): interface for supported pptxGenJS items; auto-insert …
singerla Jan 31, 2025
d24c7ba
feat(chart): support 'a:fld' data label style for scatter charts
singerla Jan 31, 2025
255cc10
chore(chart): removing a 'a:fld' data label remains unsupported
singerla Jan 31, 2025
33ab333
chore(generate): pass proper types to SupportedPptxGenJSSlide
singerla Jan 31, 2025
c0495d9
v0.6.3
singerla Jan 31, 2025
9ff169d
feat(generate): allow multiple pptxgenjs creates in callback
singerla Jan 31, 2025
753d008
v0.6.4
singerla Jan 31, 2025
875a285
v0.6.5
singerla Jan 31, 2025
f6bcf68
chore(generate): use custom pptxGenJS instance; expose IPptxGenJSSlide;
singerla Feb 3, 2025
e65784f
chore(generate): use custom pptxGenJS instance; expose IPptxGenJSSlide;
singerla Feb 3, 2025
6ed9b07
chore(generate): allow promises in slide.generate callbacks
singerla Feb 3, 2025
bb7fa9b
v0.6.6
singerla Feb 3, 2025
ac265d5
chore(generate): use single slide in tmp file (WIP)
singerla Feb 7, 2025
ce77d7b
chore(generate): use pptxGenJs output buffer instead of tmp file
singerla Feb 18, 2025
4c8a709
feat(link): support for external and internal link (WIP)
singerla Feb 24, 2025
5a42246
Feat: Initial Hyperlink Support (Backfitted from MP70)
MP70 Feb 25, 2025
1990f19
Merge pull request #150 from singerla/feat-hyperlinks
singerla Feb 25, 2025
01529c2
v0.6.7
singerla Feb 25, 2025
70a3f63
fix: handle hyperlink (all) when copying whole slide.
MP70 Feb 27, 2025
7e808bf
Rename: hyperlink test file
MP70 Feb 27, 2025
34b57ba
WIP Feat: Hyperlink helpers (w/tests) for full hyperlink manipulation ✅🔗
MP70 Feb 27, 2025
31a8109
chore(lib): add AutomizerFile type to exports
singerla Feb 25, 2025
e563a69
Improve addHyperlink Functionality & Fix pptxgenjs Compatibility
MP70 Mar 15, 2025
3b474a7
Merge remote-tracking branch 'origin/feat-hyperlinks' into feat-hyper…
singerla Mar 20, 2025
8925114
Merge pull request #155 from singerla/feat-hyperlinks
singerla Mar 20, 2025
2adbb0b
Merge pull request #141 from singerla/snyk-upgrade-98e254183ec2058b34…
singerla Mar 20, 2025
00c9468
Merge branch 'main' into dependabot/npm_and_yarn/cross-spawn-7.0.6
singerla Mar 20, 2025
e59b2fa
Merge pull request #133 from singerla/dependabot/npm_and_yarn/cross-s…
singerla Mar 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 49 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# pptx-automizer: A Powerful .pptx Modifier for Node.js

`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).
`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).

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).

`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.

Expand Down Expand Up @@ -36,6 +38,11 @@ If you require commercial support for complex .pptx automation, you can explore
- [Modify Charts](#modify-charts)
- [Modify Extended Charts](#modify-extended-charts)
- [Remove elements from a slide](#remove-elements-from-a-slide)
- [🔗 Hyperlink Management](#🔗-hyperlink-management)
- [Hyperlink Helper Functions](#hyperlink-helper-functions)
- [Adding Hyperlinks](#adding-hyperlinks)


- [Tipps and Tricks](#tipps-and-tricks)
- [Loop through the slides of a presentation](#loop-through-the-slides-of-a-presentation)
- [Quickly get all slide numbers of a template](#quickly-get-all-slide-numbers-of-a-template)
Expand All @@ -44,10 +51,10 @@ If you require commercial support for complex .pptx automation, you can explore
- [Import and modify slide Masters](#import-and-modify-slide-masters)
- [Track status of automation process](#track-status-of-automation-process)
- [More examples](#more-examples)
- [Create a new modifier](#create-a-new-modifier)
- [Troubleshooting](#troubleshooting)
- [Testing](#testing)
- [Special Thanks](#special-thanks)

<!-- TOC -->

# Requirements and Limitations
Expand Down Expand Up @@ -174,6 +181,13 @@ const automizer = new Automizer({

// use a callback function to track pptx generation process.
// statusTracker: myStatusTracker,

// Use 1 to show warnings or 2 for detailed information
// 0 disables logging
verbosity: 1,

// Remove all unused placeholders to prevent unwanted overlays:
cleanupPlaceholders: false
});

// Now we can start and load a pptx template.
Expand Down Expand Up @@ -582,6 +596,36 @@ pres
});
```

## 🔗 Hyperlink Management

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.

### Hyperlink Helper Functions

Three core functions are available for all your hyperlink needs:

| Function | Description |
|----------|-------------|
| `addHyperlink` | Add a new hyperlink to an element |


### Adding Hyperlinks

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:

```ts
// Add an external hyperlink
slide.modifyElement('TextShape', modify.addHyperlink('https://example.com'));


// Add an internal slide link (to slide 3)
slide.modifyElement('TextShape', (element, relation) => {
modify.addHyperlink(3)(element, relation);
});
```

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.

# Tipps and Tricks

## Loop through the slides of a presentation
Expand All @@ -590,7 +634,7 @@ If you would like to modify elements in a single .pptx file, it is important to

This is how it works internally:

- Load a root template to append slides to it
- Load a root template to append slides to
- (Probably) load root template again to modify slides
- Load other templates
- Append a loaded slide to (probably truncated) root template
Expand Down Expand Up @@ -622,7 +666,7 @@ const run = async () => {
// Defining a "name" as second params makes it a little easier
.load(`SlideWithShapes.pptx`, 'myTemplate');

// Get useful information about loaded templates:
// This is brandnew: get useful information about loaded templates:
const myTemplates = await pres.getInfo();
const mySlides = myTemplates.slidesByTemplate(`myTemplate`);

Expand Down Expand Up @@ -783,10 +827,6 @@ To specify another slideLayout for an added output slide, you need to count slid

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).

If you require to modify slide master backgrounds, please refer to
- [Modify master background color](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-master-background-color.test.ts).
- [Modify master background image](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-master-background-image.test.ts).

```ts
// Import another slide master and all its slide layouts.
// Index 1 means, you want to import the first of all masters:
Expand Down Expand Up @@ -861,55 +901,6 @@ const automizer = new Automizer({
});
```

## Create a new modifier

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.

Let's first take a look at a (simplified) existing modifier: `ModifyTextHelper.content('This is my text')`.

```ts
// "setTextContent" is a function that returns a function.
// A "label" argument needs to be passed to "setTextContent".
const setTextContent = function (label: number | string) {
// On setup, we can handle the argument.
const newTextContent = String(label);

// A new function is returned to apply the label at runtime.
return function (shape: XmlElement) {
// "shape" contains a modifiable xmldom object.
// You can use a selector to find the required 'a:t' element:
const textElement = shape.getElementsByTagName('a:t').item(0);

// You can now apply the "newTextContent".
if (textElement?.firstChild) {
// Refer to xmldom for available functions.
textElement.firstChild.textContent = newTextContent;
}
// It is possible to output the xml to console at any time.
// XmlHelper.dump(element);
};
};
```
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.

You can use the modifier e.g. on adding an element:

```ts
pres.addSlide('SlideWithShapes.pptx', 2, (slide) => {
// This will import the 'Drum' shape
slide.modifyElement('Cloud', [
// 1. Dump the original xml:
// Notice: don't call XmlHelper.dump, just pass it
XmlHelper.dump,
// 2. Apply modifier from the example above:
setTextContent('New text'),
XmlHelper.dump,
]);
});
```

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).

## More examples

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.:
Expand All @@ -922,17 +913,13 @@ Take a look into [**tests**-directory](https://github.com/singerla/pptx-automize
- [Update chart legend](https://github.com/singerla/pptx-automizer/blob/main/__tests__/modify-chart-legend.test.ts)

## Troubleshooting

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:

- **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.
- **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).
- **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))
- **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.
- **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).
- **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))
- **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))

- **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.

If none of these could help, please don't hesitate to [talk about it](https://github.com/singerla/pptx-automizer/issues/new).

Expand Down
10 changes: 8 additions & 2 deletions __tests__/add-external-image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('Load external media, add/modify image and set image target', async () => {

const pres = automizer
.loadRoot(`RootTemplate.pptx`)
.loadMedia([`feather.png`, `test.png`])
.loadMedia([`feather.png`, `test.png`, `Dàngerous Dinösaur.png`])
.loadMedia(`test.png`, `${__dirname}/../__tests__/media`, 'pre_')
.load(`SlideWithShapes.pptx`, 'shapes')
.load(`SlideWithImages.pptx`, 'images');
Expand All @@ -34,10 +34,16 @@ test('Load external media, add/modify image and set image target', async () => {
]);
});

pres.addSlide('images', 1, (slide) => {
slide.modifyElement('Grafik 5', [
ModifyImageHelper.setRelationTarget('Dàngerous Dinösaur.png'),
]);
});

const result = await pres.write(`add-external-image.test.pptx`);

// expect a 5x3cm light-blue duotone feather instead of imagePNG cord loop on page 1
// expect imagePNG cord loop on page 2 instead of cut tree jpg

expect(result.images).toBe(3);
expect(result.images).toBe(5);
});
1 change: 1 addition & 0 deletions __tests__/add-slide-master.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test('Append and modify slideMastes and use slideLayouts', async () => {
const automizer = new Automizer({
templateDir: `${__dirname}/pptx-templates`,
outputDir: `${__dirname}/pptx-output`,
verbosity: 2,
});

const pres = await automizer
Expand Down
11 changes: 9 additions & 2 deletions __tests__/add-slide-notes.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import Automizer from '../src/automizer';
import { vd } from '../src/helper/general-helper';

test('create presentation and append slides with notes', async () => {
const automizer = new Automizer({
templateDir: `${__dirname}/pptx-templates`,
outputDir: `${__dirname}/pptx-output`
outputDir: `${__dirname}/pptx-output`,
});

const pres = automizer.loadRoot(`RootTemplate.pptx`)
const pres = automizer
.loadRoot(`RootTemplate.pptx`)
.load(`SlideWithNotes.pptx`, 'notes');

pres.addSlide('notes', 1);

const creationIds = await pres.setCreationIds();
// This will print out the first line of a slide note field
// OR the slide title, if there is no slide note present:
console.log(creationIds[0].slides[0].info);

const result = await pres.write(`add-slide-notes.test.pptx`);

expect(result.slides).toBe(2);
Expand Down
22 changes: 22 additions & 0 deletions __tests__/add-svg-images.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Automizer from '../src/automizer';

test('create presentation and append slides with images', async () => {
const automizer = new Automizer({
templateDir: `${__dirname}/pptx-templates`,
outputDir: `${__dirname}/pptx-output`,
});

const pres = automizer
.loadRoot(`RootTemplate.pptx`)
.load(`EmptySlide.pptx`, 'empty')
.load(`SVGImages.pptx`, 'images');

pres.addSlide('empty', 1, (slide) => {
slide.addElement('images', 1, 'Heart');
slide.addElement('images', 1, 'Leaf');
});

const result = await pres.write(`add-svg-images.test.pptx`);

expect(result.images).toBe(4);
});
Loading