code: def get_page_count(filename: str) -> int:
      
      log.debug("Getting page count for {!r}", filename)
      require(PDFTK, HELP_MISSING_PDFTK)
      stdout, _ = run([PDFTK, filename, "dump_data"], get_output=True)
      regex = re.compile(r"^NumberOfPages: (\d+)$", re.MULTILINE)
      m = regex.search(stdout)
      if m:
          return int(m.group(1))
      raise ValueError("Can't get PDF page count for: {!r}".format(filename))
docs: How many pages are in a PDF?