docs: def convert_PDF_to_plaintext(fpath, keep_layout=False):
      """Convert PDF to txt using pdftotext.
  
      Take the path to a PDF file and run pdftotext for this file, capturing
      the output.
  
      :param fpath: (string) path to the PDF file
      :return: (list) of unicode strings (contents of the PDF file translated
      into plaintext; each string is a line in the document.)
      """
      if keep_layout:
          layout_option = "-layout"
      else:
          layout_option = "-raw"
      status = 0
      doclines = []
      # Pattern to check for lines with a leading page-break character.
      # If this pattern is matched, we want to split the page-break into
      # its own line because we rely upon this for trying to strip headers
      # and footers, and for some other pattern matching.
      p_break_in_line = re.compile(r'^\s*\f(.+)$', re.UNICODE)
      # build pdftotext command:
      cmd_pdftotext = [current_app.config.get("CLASSIFIER_PATH_PDFTOTEXT"),
                       layout_option, "-q",
                       "-enc", "UTF-8", fpath, "-"]
      current_app.logger.debug("* %s" % ' '.join(cmd_pdftotext))
      # open pipe to pdftotext:
      pipe_pdftotext = subprocess.Popen(cmd_pdftotext, stdout=subprocess.PIPE)
  
      # read back results:
      for docline in pipe_pdftotext.stdout:
          unicodeline = docline.decode("utf-8")
          # Check for a page-break in this line:
          m_break_in_line = p_break_in_line.match(unicodeline)
          if m_break_in_line is None:
              # There was no page-break in this line. Just add the line:
              doclines.append(unicodeline)
          else:
              # If there was a page-break character in the same line as some
              # text, split it out into its own line so that we can later
              # try to find headers and footers:
              doclines.append(u"\f")
              doclines.append(m_break_in_line.group(1))
  
      current_app.logger.debug(
          "* convert_PDF_to_plaintext found: %s lines of text" % len(doclines)
      )
  
      # finally, check conversion result not bad:
      if pdftotext_conversion_is_bad(doclines):
          status = 2
          doclines = []
  
      return (doclines, status)