@@ -25,6 +25,7 @@ npm install pptx-automizer
2525## Example
2626``` js
2727import Automizer from " pptx-automizer"
28+ import { setPosition , setChartData , dump } from " pptx-automizer/helper/modify"
2829
2930// First, let's set some preferences
3031const automizer = new Automizer ({
@@ -59,6 +60,37 @@ pres.addSlide('image', 1, (slide) => {
5960 })
6061})
6162
63+ // It is possible to modify an existing element on a newly added slide.
64+ pres .addSlide (' shapes' , 2 , (slide ) => {
65+ slide .modifyElement (' Drum' , [
66+ // You can use some of the builtin modifiers to edit a shape's xml:
67+ setPosition ({x: 1000000 , h: 5000000 , w: 5000000 }),
68+ // Log your target xml into the console:
69+ dump
70+ ])
71+ })
72+
73+ // Modify an existing chart on an added slide.
74+ pres .addSlide (' charts' , 2 , (slide ) => {
75+ slide .modifyElement (' ColumnChart' , [
76+ // Use an object like this to inject the new chart data.
77+ // Make sure there is enough space in the template chart.
78+ setChartData ({
79+ series: [
80+ { label: ' series 1' },
81+ { label: ' series 2' },
82+ { label: ' series 3' },
83+ ],
84+ categories: [
85+ { label: ' cat 2-1' , values: [ 50 , 50 , 20 ] },
86+ { label: ' cat 2-2' , values: [ 14 , 50 , 20 ] },
87+ { label: ' cat 2-3' , values: [ 15 , 50 , 20 ] },
88+ { label: ' cat 2-4' , values: [ 26 , 50 , 20 ] }
89+ ]
90+ })
91+ ])
92+ })
93+
6294// Finally, we want to write the output file.
6395pres .write (` myPresentation.pptx` ).then (summary => {
6496 console .log (summary)
0 commit comments