Pptxgenjs: Placeholder type Body is defaulting in a hanging indent

Created on 10 Sep 2019  路  6Comments  路  Source: gitbrent/PptxGenJS

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.

https://jsfiddle.net/7muse9ca/

bug

All 6 comments

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.

image

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

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="&#x2022;"/>'
            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:
image

Thanks @colmben

@Smithvinayakiya - This is now fixed in master branch.

Thanks @gitbrent

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TinkerJack-zz picture TinkerJack-zz  路  6Comments

jobnte picture jobnte  路  5Comments

shyam2794 picture shyam2794  路  6Comments

cwilkens picture cwilkens  路  6Comments

adrienco88 picture adrienco88  路  3Comments