Update for version 3.3.0: bodyProp renamed to _bodyProp. Also, there is now a property called wrap (boolean, default: true), but it does nothing at the moment.
Hi there,
Please specify what version of the library you are using: [3.2.1]
Please specify what version(s) of PowerPoint you are targeting: [2019 & 365]
There is no obvious property to control the "Wrap text in shape" option for shapes and text boxes in the documentation.
But there is in code: https://github.com/gitbrent/PptxGenJS/blob/master/src/gen-xml.ts#L1038
Using
const options = {
bodyProp: {
wrap: 'none'
}
};
none will uncheck it, while square will check it.
There is a textWrap property mentioned in https://github.com/gitbrent/PptxGenJS/blob/master/src/gen-xml.ts#L516 , but I don't know if this code is related.
And there is the bodyProp.wrap property in https://github.com/gitbrent/PptxGenJS/blob/master/src/core-interfaces.ts#L648 , but with a wrong type and wrap https://github.com/gitbrent/PptxGenJS/blob/master/src/core-interfaces.ts#L706 as a boolean. I guess, the first one is a bug, the other might be correct, if an easy usage is intended for future versions.
Also, I guess, the bodyProp.wrap property has some relevance for how text will flow around an image or chart or media object, but I'm not sure on that part.
+1 for the feature or an explanation on how to implement it if it's hidden but available :).
Wrapping text is usually done by powerpoint's internal rendering engine when you open the pptx. I'd be interested to know if this library can enable "wrap" on overflow and if it has any affect on the text.
As of v3.3.1 there's a new demo slide with examples and explanations for how wrap works.
Hi @gitbrent ,
setting the property wrap for text options doesn't work.
Setting options.wrap: false won't do anything.
var pptx = new PptxGenJS();
var slide = pptx.addSlide();
slide.addText(
'A long text. A very long text. It is so long prompting the question when does it end? Maybe now, or never? All things end, I guess. So, is it the end for now?',
{ x:1, y:1, w: 1, h:3, align:'center', fill:{ color:pptx.SchemeColor.background2, transparency:50 }, wrap: false }
);
pptx.writeFile('PptxGenJS-Sandbox-'+getTimestamp())
.then(function(fileName){ console.log('Saved! File Name: '+fileName) });
Still need to work with options._bodyProp.wrap: none.
var pptx = new PptxGenJS();
var slide = pptx.addSlide();
slide.addText(
'A long text. A very long text. It is so long prompting the question when does it end? Maybe now, or never? All things end, I guess. So, is it the end for now?',
{ x:1, y:1, w: 1, h:3, align:'center', fill:{ color:pptx.SchemeColor.background2, transparency:50 }, _bodyProp: { wrap: 'none' } }
);
pptx.writeFile('PptxGenJS-Sandbox-'+getTimestamp())
.then(function(fileName){ console.log('Saved! File Name: '+fileName) });
I think options.wrap needs to be included in https://github.com/gitbrent/PptxGenJS/blob/master/src/gen-xml.ts#L1054
Also, I couldn't find any demos that use options.wrap.
Best regards
Duh, I was thinking of the work just done on fit and its new demo slide!

Yes, you're correct, the wrap property is not working as intended. I'll get a demo added and the code fixed for v3.5.0
Fixed! Thanks @CroniD
var pptx = new PptxGenJS();
var slide = pptx.addSlide();
slide.addText("A long text. A very long text. It is so long prompting the question when does it end?", {
x: 0.5,
y: 0.5,
w: 4,
h: 2,
align: "center",
fill: { color: pptx.SchemeColor.background2, transparency: 50 },
wrap: false,
});
slide.addText("A long text. A very long text. It is so long prompting the question when does it end?", {
x: 0.5,
y: 3,
w: 4,
h: 2,
align: "center",
fill: { color: pptx.SchemeColor.background2, transparency: 50 },
wrap: true,
});
pptx.writeFile("PptxGenJS-Sandbox-" + getTimestamp()).then(function (fileName) {
console.log("Saved! File Name: " + fileName);
});

Hi Team, when version 3.5.0 will be available. I am also looking for wrap feature.
Hi @sachinbagla86 ,
you can use it already in 3.4.0. Just set it like options._bodyProp: { wrap: 'none' } (use square to enable it, which is the default). Once 3.5.0 is released you need to change it to options.wrap: true.