Skip to content

Commit ff6b963

Browse files
authored
doc(pres): Add sort slide chapter to readme
1 parent dac9596 commit ff6b963

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,13 @@ pres
180180
```
181181

182182

183-
## How to sort output slides
183+
## Sort output slides
184184

185-
You can also insert added slides between existing slides.
185+
There are three ways to arrange slides in an output presentation.
186+
187+
1. By default, all slides will be appended to the existing slides in your root template. The order of `addSlide`-calls will define slide sortation in output presentation.
188+
189+
2. You can alternatively remove all existing slides by setting the `removeExistingSlides` flag to true. The first slide added with `addSlide` will be first slide in the output presentation. If you want to insert slides from root template, you need to load it a second time.
186190

187191
```ts
188192
import Automizer from "pptx-automizer"
@@ -214,6 +218,31 @@ pres.write(`mySortedPresentation.pptx`).then(summary => {
214218
})
215219
```
216220

221+
222+
3. Use `sortSlides`-callback
223+
You can pass an array of numbers and create a callback and apply it to `presentation.xml`.
224+
This will also work without adding slides.
225+
226+
Slides will be appended to the existing slides by slide number (starting from 1). You may find irritating results in case you skip a slide number.
227+
228+
```ts
229+
import ModifyPresentationHelper from './helper/modify-presentation-helper';
230+
231+
//
232+
// You may truncate root template or you may not
233+
// ...
234+
235+
// It is possible to skip adding slides, try sorting an unmodified presentation
236+
pres.addSlide('charts', 1);
237+
.addSlide('charts', 2);
238+
.addSlide('images', 1);
239+
.addSlide('images', 2);
240+
241+
const order = [3, 2, 4, 1];
242+
pres.modify(ModifyPresentationHelper.sortSlides(order));
243+
```
244+
245+
217246
## Track status of automation process
218247

219248
When creating large presentations, you might want to have some information about the current status. Use a custom status tracker:

0 commit comments

Comments
 (0)