My Question: How do you set text to be a title or subtitle in a Google Doc using Google Apps Script? (see a visual example below)
In Google Apps Script documentation on formatting paragraphs they show the different types of ParagraphHeadings in the ParagraphHeading class and then there's the Attribute class which can be assigned to a paragraph which has some styling attributes. However, neither of these has a way to set any text as a title or a subtitle in the document. How is that accomplished?
I'm looking for something like this:
var doc = DocumentApp.getActiveDocument();
// Append a paragraph, with title.
var par1 = doc.appendParagraph("Title");
par1.setHeading(DocumentApp.ParagraphHeading.TITLE);
// Append a paragraph, with subtitle.
var par2 = doc.appendParagraph("SubTitle");
par2.setHeading(DocumentApp.ParagraphHeading.SUBTITLE);
// Append a paragraph, with heading 1.
var par3 = doc.appendParagraph("Heading 1");
par3.setHeading(DocumentApp.ParagraphHeading.HEADING1);
Here's what I mean:
