code: def convert_pdf_to_txt(pdf, startpage=None):
      
      if startpage is not None:
          startpageargs = ['-f', str(startpage)]
      else:
          startpageargs = []
      stdout = subprocess.Popen(["pdftotext", "-q"] + startpageargs + [pdf, "-"],
                                stdout=subprocess.PIPE).communicate()[0]
      # python2 and 3
      if not isinstance(stdout, str):
          stdout = stdout.decode()
      return stdout
docs: Convert a pdf file to text and return the text.
  
      This method requires pdftotext to be installed.
  
      Parameters
      ----------
      pdf : str
          path to pdf file
      startpage : int, optional
          the first page we try to convert
  
      Returns
      -------
      str
          the converted text