code: def _cached_pages(self, target_page=-1):
          
          try:
              # pdfminer < 20131022
              self._pages_iter = self._pages_iter or self.doc.get_pages()
          except AttributeError:
              # pdfminer >= 20131022
              self._pages_iter = self._pages_iter or \
                  PDFPage.create_pages(self.doc)
  
          if target_page >= 0:
              while len(self._pages) <= target_page:
                  next_page = next(self._pages_iter)
                  if not next_page:
                      return None
                  next_page.page_number = 0
                  self._pages += [next_page]
              try:
                  return self._pages[target_page]
              except IndexError:
                  return None
          self._pages += list(self._pages_iter)
          return self._pages
docs: Get a page or all pages from page generator, caching results.
          This is necessary because PDFMiner searches recursively for pages,
          so we won't know how many there are until we parse the whole document,
          which we don't want to do until we need to.