Apps Script: get Paragraph Formatting
Hacky workarounds 103
As you may have noticed, the Apps Script paragraph.getAttributes() function returns mostly nulls.
This is because paragraph styles are inherited from the named styles unless they’re explicitly set on the paragraph (as demonstrated in this Advanced Docs sample), over-riding the default styles. Unfortunately, the Apps Script Document Service doesn’t provide an API to get the named styles.
Fortunately, the Advanced Docs Service does. The following snippet demonstrates its use; one thing to be aware of is that opening a large document with the Advanced Docs Service can be slow (eg. 30+ seconds for a 150 page document).
When building your own Advanced Docs Service scripts, this rather hard-to-read discovery document is a helpful tool for navigating the available methods. An astonishing amount of supplemental context is available in the Overview.