Pptxgenjs: autoFit text option has no effect?

Created on 21 Mar 2018  路  3Comments  路  Source: gitbrent/PptxGenJS

I'm trying to create a text box with the autofit option, but it does not appear to be working. The box always has a fixed size and the text overflows outside of it. Am I missing something?

const PptxGenJS = require("pptxgenjs");

let pptx = new PptxGenJS();
let slide = pptx.addNewSlide();

slide.addText('The quick brown fox jumps over the lazy dog',
     { isTextBox: true, autoFit: true, x: 1.0, y: 1.0, w: 1.0, fontSize: 12});

pptx.save('SamplePresentation');

Edit / Add - I opened the file in both ppt for Windows Version 1802 and in ppt for Mac v. 15.39 and saw the same result.

question

All 3 comments

Hi, I'm also getting that problem. Have u found out what was wrong?

My suspicion at this point is that PPT does not apply the autofit transformation on opening the presentation, but rather only when you edit the text in the shape, because:

  1. If you generate a shape via the library and then create an identical slide in PPT, the resulting XML is almost identical and doesn't seem to have any semantic differences.

  2. If you generate a shape via the library, open the .pptx file, and edit the text in the shape in any way, then PPT does resize the shape at that point to match the resulting text.

@DSheffield,

You are correct. Only the PowerPoint runtime can read the text/formatting of a shape's contents and fit the shape's w and h to that calculated size. There's no code i can add that'll accomplish the same outcome. OpenXML only goes so far.

Lastly, the autofit option does work for sizing the Textbox Shape's width given the correct options, so it's not a matter of it not working, it's just a limited option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinresol picture kevinresol  路  3Comments

jobnte picture jobnte  路  5Comments

simonjcarr picture simonjcarr  路  6Comments

bestis picture bestis  路  6Comments

Skiizoo picture Skiizoo  路  6Comments