docs: def get_bounding_box_list_ghostscript(input_doc_fname, res_x, res_y, full_page_box):
      """Call Ghostscript to get the bounding box list.  Cannot set a threshold
      with this method."""
  
      if not gs_executable: init_and_test_gs_executable(exit_on_fail=True)
      res = str(res_x) + "x" + str(res_y)
      box_arg = "-dUseMediaBox" # should be default, but set anyway
      if "c" in full_page_box: box_arg = "-dUseCropBox"
      if "t" in full_page_box: box_arg = "-dUseTrimBox"
      if "a" in full_page_box: box_arg = "-dUseArtBox"
      if "b" in full_page_box: box_arg = "-dUseBleedBox" # may not be defined in gs
      gs_run_command = [gs_executable, "-dSAFER", "-dNOPAUSE", "-dBATCH", "-sDEVICE=bbox",
                      box_arg, "-r"+res, input_doc_fname]
      # Set printOutput to True for debugging or extra-verbose with Ghostscript's output.
      # Note Ghostscript writes the data to stderr, so the command below must capture it.
      try:
          gs_output = get_external_subprocess_output(gs_run_command,
                            print_output=False, indent_string="   ", env=gs_environment)
      except UnicodeDecodeError:
          print("\nError in pdfCropMargins:  In attempting to get the bounding boxes"
                "\nGhostscript encountered characters which cannot be decoded by the"
                "\n'utf-8' codec.",
                file=sys.stderr)
          cleanup_and_exit(1)
  
      bounding_box_list = []
      for line in gs_output:
          split_line = line.split()
          if split_line and split_line[0] == r"%%HiResBoundingBox:":
              del split_line[0]
              if len(split_line) != 4:
                  print("\nWarning from pdfCropMargins: Ignoring this unparsable line"
                        "\nwhen finding the bounding boxes with Ghostscript:",
                        line, "\n", file=sys.stderr)
                  continue
              # Note gs reports values in order left, bottom, right, top,
              # i.e., lower left point followed by top right point.
              bounding_box_list.append([float(split_line[0]),
                                      float(split_line[1]),
                                      float(split_line[2]),
                                      float(split_line[3])])
  
      if not bounding_box_list:
          print("\nError in pdfCropMargins: Ghostscript failed to find any bounding"
                "\nboxes in the document.", file=sys.stderr)
          cleanup_and_exit(1)
      return bounding_box_list