How do you tell whether text fits within its bounding shape using Google Slides API?

半世苍凉 提交于 2019-12-10 16:48:55

问题


I am doing a merge of data from a google spreadsheet to a slides presentation using placeholder shapes and apps script, something along the lines of this example.

I have the merge working well. The first issue I am having though is that the text is not bound by the shape that contains it. If the text does not fit within the bounding shape it simply overflows:

That wouldn't be such a problem if i could then somehow tell programatically that the text has overflowed. As far as I can tell though I can only get the height of the bounding shape. Which doesn't change even though it now "contains" text that covers a much greater height on the slide. I don't seem to be able to get the height of the actual text.

Is there any way to tell what the height of the textrange is, or that it has overflowed, so that I can then either adjust some feature of the text (the fontsize, or the length of the actual text etc) so that the text is bound by the textbox? Or at least alert the user that the text has overflowed.

The powerpoint equivalent of this would be textrange.boundheight if that helps describe the property I am looking for, with a similar property I would then hopefully be able to implement something similar to the AutoSize feature.

The merge of text to a slide without some way to fit the text to the placeholder shapes doesn't seem that useful to me.

来源:https://stackoverflow.com/questions/53218561/how-do-you-tell-whether-text-fits-within-its-bounding-shape-using-google-slides

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!