docs: def text_lines_from_local_file(document, remote=False):
      """Return the fulltext of the local file.
  
      @param document: fullpath to the file that should be read
      @param remote: boolean, if True does not count lines
  
      @return: list of lines if st was read or an empty list
      """
      try:
          if is_pdf(document):
              if not executable_exists("pdftotext"):
                  current_app.logger.error(
                      "pdftotext is not available on the system."
                  )
              cmd = "pdftotext -q -enc UTF-8 %s -" % re.escape(document)
              out = subprocess.Popen(["pdftotext", "-q", "-enc", "UTF-8",
                                      document, "-"],
                                     universal_newlines=True,
                                     stdout=subprocess.PIPE)
              (stdoutdata, stderrdata) = out.communicate()
              lines = stdoutdata.splitlines()
              if not isinstance(stdoutdata, six.text_type):
                  # We are in Python 2. We need to cast to unicode
                  lines = [line.decode('utf8', 'replace') for line in lines]
          else:
              filestream = codecs.open(document, "r", encoding="utf8",
                                       errors="replace")
              # FIXME - we assume it is utf-8 encoded / that is not good
              lines = [line for line in filestream]
              filestream.close()
      except IOError as ex1:
          current_app.logger.error("Unable to read from file %s. (%s)"
                                   % (document, ex1.strerror))
          return []
  
      # Discard lines that do not contain at least one word.
      return [line for line in lines if _ONE_WORD.search(line) is not None]