I know it is possible to get the text style of a selected word using
getSelection().getTextRange().getTextStyle()
but if I want to retrieve text styles from a previous slide word by word (getting each word's text style individually), is there a way to do that?
You can iterate through the PageElements of the slide, and retrieve the text style from each element.
For each
PageElement, you would have to check whether its type has TextRange as one of its properties (only Shape and TextCell elements haveTextRange). If you try to retrieve text from an element that does not contain text, you might end up getting an error.Then, for each
textRangethat you retrieve, you can iterate through its runs (the different segments contained in this text that have a different text style), and retrieve the text style for each run.Code sample:
Note:
TextStyleof all the text belonging toShapeelements in the slide.TableCellelements can also contain text, so if you want to retrieve that information too, you would have to modify the script accordingly (take a look at Class Table).Reference: