Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placeholder type Body is defaulting in a hanging indent #589

Closed
colmben opened this issue Sep 10, 2019 · 6 comments
Closed

Placeholder type Body is defaulting in a hanging indent #589

colmben opened this issue Sep 10, 2019 · 6 comments
Assignees
Milestone

Comments

@colmben
Copy link

colmben commented Sep 10, 2019

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/

@gitbrent
Copy link
Owner

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.

@mode777
Copy link

mode777 commented Nov 15, 2019

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.

@gitbrent gitbrent added this to the 3.1.0 milestone Nov 18, 2019
@gitbrent gitbrent modified the milestones: 3.1.0, 3.2.0 Jan 21, 2020
@Smithvinayakiya
Copy link

Hi @gitbrent
Any update on this issue?? Any timeline with regards to the solution??

@gitbrent
Copy link
Owner

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

gitbrent added a commit that referenced this issue May 16, 2020
gitbrent added a commit that referenced this issue May 16, 2020
@gitbrent
Copy link
Owner

gitbrent commented May 16, 2020

Thanks @colmben

@Smithvinayakiya - This is now fixed in master branch.

@Smithvinayakiya
Copy link

Thanks @gitbrent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants