Skip to content
New issue

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

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

Already on GitHub? # to your account

[QUESTION] Setting the "Wrap text in shape" option #771

Closed
2 of 4 tasks
CroniD opened this issue Jun 14, 2020 · 8 comments
Closed
2 of 4 tasks

[QUESTION] Setting the "Wrap text in shape" option #771

CroniD opened this issue Jun 14, 2020 · 8 comments
Assignees
Milestone

Comments

@CroniD
Copy link

CroniD commented Jun 14, 2020

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,

Category

  • Enhancement
  • Bug
  • Question
  • Documentation gap/issue

Version

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]

Expected / Desired Behavior / Question

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.

@gitbrent gitbrent self-assigned this Jun 16, 2020
@salievn
Copy link

salievn commented Jun 20, 2020

+1 for the feature or an explanation on how to implement it if it's hidden but available :).

@mszbot
Copy link

mszbot commented Oct 28, 2020

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.

@gitbrent
Copy link
Owner

gitbrent commented Jan 9, 2021

As of v3.3.1 there's a new demo slide with examples and explanations for how wrap works.

@gitbrent gitbrent closed this as completed Jan 9, 2021
@CroniD
Copy link
Author

CroniD commented Jan 10, 2021

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

@gitbrent
Copy link
Owner

gitbrent commented Jan 12, 2021

Duh, I was thinking of the work just done on fit and its new demo slide!
Screen Shot 2021-01-11 at 18 42 08

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

@gitbrent gitbrent reopened this Jan 12, 2021
@gitbrent gitbrent added this to the 3.5.0 milestone Jan 12, 2021
gitbrent added a commit that referenced this issue Jan 12, 2021
gitbrent added a commit that referenced this issue Jan 12, 2021
@gitbrent
Copy link
Owner

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);
});

Screen Shot 2021-01-11 at 19 04 18

@sachinbagla86
Copy link

Hi Team, when version 3.5.0 will be available. I am also looking for wrap feature.

@CroniD
Copy link
Author

CroniD commented Feb 3, 2021

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.

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

No branches or pull requests

5 participants