docs: def pdftotext_conversion_is_bad(txtlines):
      """Check if conversion after pdftotext is bad.
  
      Sometimes pdftotext performs a bad conversion which consists of many
      spaces and garbage characters.
  
      This method takes a list of strings obtained from a pdftotext conversion
      and examines them to see if they are likely to be the result of a bad
      conversion.
  
      :param txtlines: (list) of unicode strings obtained from pdftotext
      conversion.
      :return: (integer) - 1 if bad conversion; 0 if good conversion.
      """
      # Numbers of 'words' and 'whitespaces' found in document:
      numWords = numSpaces = 0
      # whitespace character pattern:
      p_space = re.compile(unicode(r'(\s)'), re.UNICODE)
      # non-whitespace 'word' pattern:
      p_noSpace = re.compile(unicode(r'(\S+)'), re.UNICODE)
      for txtline in txtlines:
          numWords = numWords + len(p_noSpace.findall(txtline.strip()))
          numSpaces = numSpaces + len(p_space.findall(txtline.strip()))
      if numSpaces >= (numWords * 3):
          # Too many spaces - probably bad conversion
          return True
      else:
          return False