title: Google Docs: Formatting Title and Subtitle
body: <p><strong>My Question:</strong> How do you set text to be a title or subtitle in a Google Doc using Google Apps Script? (see a visual example below)</p>
  
  <p>In Google Apps Script documentation on formatting paragraphs they show the different types of ParagraphHeadings in the <a href="https://developers.google.com/apps-script/class_documentapp_paragraphheading" rel="nofollow noreferrer">ParagraphHeading class</a> and then there's the <a href="https://developers.google.com/apps-script/class_documentapp_attribute" rel="nofollow noreferrer">Attribute class</a> 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?</p>
  
  <p>I'm looking for something like this:</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>Here's what I mean:</p>
  
  <p><img src="https://i.stack.imgur.com/4YXus.png" alt="Headings"></p>