Hi,
Thanks for a great library!
I am seeing an issue whereby when I try to add text using a placeholder of type Body I am getting a default hanging indent of .95cm. You can see this in the 3rd slide of the online Master slides demo pptx.
I can't figure out a way to change or work around this. paraSpaceBefore, paraSpaceAfter and indentLevel all seem to be ignored when using placeholders. Is it possible to use a placeholder to add text without getting that hanging indent?
Thanks :)
Edit - a fiddle illustrating the point, the added text has a hanging indent.
Hi @colmben
Thanks for reporting this.
I just checked and the issue persists on the newest 3.0 codebase, so i'll look into what may be causing it.
These seem to be default values assumed by powerpoint if certain attributes are not set. I opened the generated file and fixed the bad formating of the placeholder. Both, indent and hangign were set.

I saved the changed file and compared the xml sources of the generated(left) and fixed(right) file:

I was able to make a quick fix by tweaking:
function genXmlParagraphProperties(textObj, isDefault) {
// code omitted....
// OPTION: bullet
// NOTE: OOXML uses the unicode character set for Bullets
// EX: Unicode Character 'BULLET' (U+2022) ==> '<a:buChar char="•"/>'
if ( typeof textObj.options.bullet === 'object' ) {
// ...
}
else if ( textObj.options.bullet == true ) {
// ...
}
else {
// added these lines
paragraphPropXml += ' indent="0"';
paragraphPropXml += ' marL="0"'
strXmlBullet = '<a:buNone/>';
}
// ...
return paragraphPropXml;
}
I could do a pull request but I haven't been able to test these changes.
Hi @gitbrent
Any update on this issue?? Any timeline with regards to the solution??
let pptx = new PptxGenJS();
pptx.defineSlideMaster({
title: "MASTER_SLIDE",
bkgd: "FFFFFF",
objects: [
{
placeholder: {
options: {
name: "title",
type: "title",
x: "5%",
y: "5%",
w: "90%",
h: "10%",
fontSize: 18,
},
text: "",
},
},
{
placeholder: {
options: {
name: "body",
type: "body",
x: "5%",
y: "20%",
w: "90%",
h: "80%",
fontSize: 14,
paraSpaceBefore: 0,
paraSpaceAfter: 0,
},
text: "",
},
},
],
});
const testSlide = pptx.addSlide("MASTER_SLIDE");
testSlide.addText("Slide Title", {
placeholder: "title",
valign: "top",
autofit: true,
});
testSlide.addText(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
{
placeholder: "body",
autofit: true,
valign: "top",
}
);
pptx.writeFile("Issue589-" + getTimestamp());
Result:

Thanks @colmben
@Smithvinayakiya - This is now fixed in master branch.
Thanks @gitbrent