code: def getText(page, output = "text"):
      
      CheckParent(page)
      dl = page.getDisplayList()
      # available output types
      formats = ("text", "html", "json", "xml", "xhtml", "dict", "rawdict")
      # choose which of them also include images in the TextPage
      images = (0, 1, 1, 0, 1, 1, 1)      # controls image inclusion in text page
      try:
          f = formats.index(output.lower())
      except:
          f = 0
      flags = TEXT_PRESERVE_LIGATURES | TEXT_PRESERVE_WHITESPACE
      if images[f] :
          flags |= TEXT_PRESERVE_IMAGES
      tp = dl.getTextPage(flags)     # TextPage with / without images
      t = tp._extractText(f)
      del dl
      del tp
      return t
docs: Extract a document page's text.
  
      Args:
          output: (str) text, html, dict, json, rawdict, xhtml or xml.
  
      Returns:
          the output of TextPage methods extractText, extractHTML, extractDICT, extractJSON, extractRAWDICT, extractXHTML or etractXML respectively. Default and misspelling choice is "text".