Skip to content

Commit 068deba

Browse files
committed
feat: pPTX workaround for using placeholders + custom sizes + custom fills: disableFillSettings
In case that you are adding a place holder field to a slide and the original field in the layout has custom fill settings, and also you want to change the size and position of the field then you must use the disableFillSettings = true setting. This is a workaround for this case.
1 parent 09d695c commit 068deba

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- Version 0.6.2:
2+
- PPTX workaround for using placeholders + custom sizes + custom fills: the disableFillSettings setting.
13
- Version 0.6.1:
24
- PPTX paragraph: more auto-fit options and more dots options.
35
- PPTX shapes more options: you can now change y,x,cx and cy for ph shapes, title, desc, hidden, nvPrAttrCode and nvPrCode.

examples/make_pptx.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,21 @@ function generateExampleSlides(callback) {
5757
{ text: 'Hello ', options: { font_size: 56 } },
5858
{
5959
text: 'World!',
60-
options: { font_size: 56, font_face: 'Arial', color: 'ffff00' }
60+
options: {
61+
font_size: 56,
62+
font_face: 'Arial',
63+
color: 'ffff00'
64+
}
6165
}
6266
],
63-
{ cx: '75%', cy: 66, y: 150 }
67+
{
68+
cx: '75%',
69+
cy: 66,
70+
y: 150,
71+
bodyProp: {
72+
normAutofit: 92500
73+
}
74+
}
6475
)
6576
// Please note that you can pass object as the text parameter to addText.
6677

@@ -71,7 +82,10 @@ function generateExampleSlides(callback) {
7182
cx: '50%',
7283
cy: '1inch',
7384
font_size: 48,
74-
color: '0000ff'
85+
color: '0000ff',
86+
bodyProp: {
87+
normAutofit: 92500
88+
}
7589
})
7690

7791
pObj = slide.addText('Two\nlines', {

lib/pptx/genpptx.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ function makePptx(genobj, new_type, options, gen_private, type_info) {
15581558
outString += shapes.createColorElements(
15591559
objs_list[i].options.fill
15601560
)
1561-
} else {
1561+
} else if (!objs_list[i].options.disableFillSettings) {
15621562
outString += '<a:noFill/>'
15631563
} // Endif.
15641564

@@ -1589,7 +1589,7 @@ function makePptx(genobj, new_type, options, gen_private, type_info) {
15891589

15901590
outString += '</a:ln>'
15911591
} // Endif.
1592-
} else {
1592+
} else if (!objs_list[i].options.disableFillSettings) {
15931593
outString += '<a:noFill/>'
15941594
} // Endif.
15951595

@@ -1878,7 +1878,7 @@ function makePptx(genobj, new_type, options, gen_private, type_info) {
18781878
if (objs_list[i].options) {
18791879
if (objs_list[i].options.fill) {
18801880
outString += shapes.createColorElements(objs_list[i].options.fill)
1881-
} else {
1881+
} else if (!objs_list[i].options.disableFillSettings) {
18821882
outString += '<a:noFill/>'
18831883
} // Endif.
18841884

@@ -1898,7 +1898,7 @@ function makePptx(genobj, new_type, options, gen_private, type_info) {
18981898

18991899
outString += '</a:ln>'
19001900
} // Endif.
1901-
} else {
1901+
} else if (!objs_list[i].options.disableFillSettings) {
19021902
outString += '<a:noFill/>'
19031903
} // Endif.
19041904

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "officegen",
33
"description": "Office Open XML Generator using Node.js streams. Supporting Microsoft Office 2007 and later Word (docx), PowerPoint (pptx,ppsx) and Excel (xlsx). This module is for all frameworks and environments. No need for any commandline tool - this module is doing everything inside it.",
4-
"version": "0.6.1",
4+
"version": "0.6.2",
55
"author": {
66
"name": "Ziv Barber",
77
"url": "https://github.com/Ziv-Barber"

tests/pptx-layouts.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,14 @@ describe('PPTX Layouts plugin', function() {
190190

191191
slide.addText('Other text', {
192192
ph: 'subTitle',
193-
phIdx: 32
193+
phIdx: 32,
194+
bodyProp: {
195+
normAutofit: 92500
196+
},
197+
x: '0em',
198+
y: '3333750em',
199+
cx: '9144601em',
200+
cy: '1432789em'
194201
})
195202

196203
//

0 commit comments

Comments
 (0)