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

autoFit is missing 'Shrink text on overflow' variation? #330

Closed
cdutson opened this issue May 4, 2018 · 2 comments
Closed

autoFit is missing 'Shrink text on overflow' variation? #330

cdutson opened this issue May 4, 2018 · 2 comments
Assignees
Milestone

Comments

@cdutson
Copy link

cdutson commented May 4, 2018

I've recently been trying to add text to a slide that is basically html content. I simplify the content using innerText and inject it.

const text = data.element.innerText; // element is an html div
slide.addText(text, { x: '0%', y: '0%', w: '100%', h: '100%', autoFit: true, valign: 'top' });

I expected this to shrink the text to fit within the box, but instead the text overflows out of the box (It's a lot of text). Looking into powerpoint itself, I found that within the text box's autofit options, there are a total of 3: Do not Autofit, Shrink text on overflow, and Resize shape to fit text. From what I understand, setting autoFit to false equates to Do not autofit and true equates to Resize shape to fit text. I'm looking for the middle option: Shrink text on overflow.

Is this currently possible with the library? I've read through the docs but nothing standing out to me.

Thanks,

@cdutson
Copy link
Author

cdutson commented May 4, 2018

Welp not 30 seconds after posting this and digging into the source code, I find shrinkText which is an undocumented property you can add to the props.

As such: slide.addText(text, { x: '0%', y: '0%', w: '100%', h: '100%', shrinkText: true, valign: 'top' }); achieves what I wanted.

I'd suggest updating the documentation to expose this prop.

@gitbrent gitbrent self-assigned this May 7, 2018
@gitbrent gitbrent added this to the 2.2.0 milestone May 7, 2018
@gitbrent
Copy link
Owner

gitbrent commented May 7, 2018

Hi @cdutson,

Thanks for letting me know about this.

I've updated the docs to include shrinkText.

addText API

@gitbrent gitbrent closed this as completed May 7, 2018
gitbrent pushed a commit that referenced this issue May 14, 2018
gitbrent pushed a commit that referenced this issue May 14, 2018
gitbrent pushed a commit that referenced this issue May 29, 2018
ericrockey pushed a commit to WeTransfer/PptxGenJS that referenced this issue Mar 24, 2020
ericrockey pushed a commit to WeTransfer/PptxGenJS that referenced this issue Mar 24, 2020
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

2 participants