title: Google Apps Script - Cannot read Bold Attribute of a Paragraph in a Google Doc
body: <p>I am trying to read Attributes of a Paragraph from a Google Document using Apps Script. When I read the attributes, some BOLD attributes are returned as null.</p>
  
  <p>Here is my sample script to read the attributes. </p>
  
  <p>// Reads the attributes of every paragraph in this Google Document and print all paragraph text that is BOLD</p>
  
  <pre><code>function readAttributes() {
    var doc = DocumentApp.getActiveDocument(); 
    var body = doc.getBody(); 
    var paras = body.getParagraphs();
    for (var i = 0; i &lt; paras.length; i++){ 
      var paragraph = paras[i];  
      var attribute = paragraph.getAttributes(); 
      if (attribute.BOLD === true) {
        Logger.log(paragraph.getText()); 
      }
    } 
  }
  </code></pre>
  
  <p>Here is a simulated sample document:
  The script is behind this Google document.  File -> Make a copy. </p>
  
  <p><a href="https://docs.google.com/document/d/13FYg8AAk6PX9TEUdgfaT-60Vi5xoQlZ9Moink5guLH0/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/document/d/13FYg8AAk6PX9TEUdgfaT-60Vi5xoQlZ9Moink5guLH0/edit?usp=sharing</a></p>
  
  <p>What is wrong with my document? Only the attribute of Question 18 is returned as BOLD and that of Question 17 is returned as null.</p>
  
  <p>The returned Attribute object for any paragraph in Google Document looks like below.</p>
  
  <pre><code> {
      FONT_SIZE=null, 
      ITALIC=null, 
      HORIZONTAL_ALIGNMENT=null, 
      INDENT_END=null,
      INDENT_START=null, 
      LINE_SPACING=1.0, 
      LINK_URL=null, 
      UNDERLINE=null, 
      BACKGROUND_COLOR=null, 
      INDENT_FIRST_LINE=null, 
      LEFT_TO_RIGHT=true, 
      SPACING_BEFORE=null, 
      HEADING=Normal, 
      SPACING_AFTER=null, 
      STRIKETHROUGH=null, 
      FOREGROUND_COLOR=null, 
      BOLD=null, 
      FONT_FAMILY=Calibri
  }
  </code></pre>
  
  <p>My Logger.log() Results:</p>
  
  <p><strong>Expected output :</strong></p>
  
  <ol start="17">
  <li>Which of the following is the most effective plan of action to take if your vehicle catches fire while you are driving?</li>
  <li>Before taking a trip, you need to inspect your tires. Which problems would require immediate action?</li>
  </ol>
  
  <p><strong>Resulted output:</strong></p>
  
  <ol start="18">
  <li>Before taking a trip, you need to inspect your tires. Which problems would require immediate action?</li>
  </ol>
  
  <p>Image showing the problem<img src="https://i.stack.imgur.com/54Fzu.png" alt=""></p>
  
  <p>So clearly Question 17 in the document has a problem and so its BOLD attribute is null. </p>