code: def convert_pdf_to_txt(filename: str = None, blob: bytes = None,
                         config: TextProcessingConfig = _DEFAULT_CONFIG) -> str:
      
      pdftotext = tools['pdftotext']
      if pdftotext:  # External command method
          if filename:
              return get_cmd_output(pdftotext, filename, '-')
          else:
              return get_cmd_output_from_stdin(blob, pdftotext, '-', '-')
      elif pdfminer:  # Memory-hogging method
          with get_filelikeobject(filename, blob) as fp:
              rsrcmgr = pdfminer.pdfinterp.PDFResourceManager()
              retstr = StringIO()
              codec = ENCODING
              laparams = pdfminer.layout.LAParams()
              device = pdfminer.converter.TextConverter(
                  rsrcmgr, retstr, codec=codec, laparams=laparams)
              interpreter = pdfminer.pdfinterp.PDFPageInterpreter(rsrcmgr,
                                                                  device)
              password = ""
              maxpages = 0
              caching = True
              pagenos = set()
              for page in pdfminer.pdfpage.PDFPage.get_pages(
                      fp, pagenos, maxpages=maxpages, password=password,
                      caching=caching, check_extractable=True):
                  interpreter.process_page(page)
              text = retstr.getvalue().decode(ENCODING)
          return text
      else:
          raise AssertionError("No PDF-reading tool available")
docs: Converts a PDF file to text.
      Pass either a filename or a binary object.