docs: def get_bounding_box_list(input_doc_fname, input_doc, full_page_box_list,
                         set_of_page_nums_to_crop, argparse_args, chosen_PdfFileWriter):
      """Calculate a bounding box for each page in the document.  The first
      argument is the filename of the document's original PDF file, the second is
      the PdfFileReader for the document.  The argument full_page_box_list is a list
      of the full-page-size boxes (which is used to correct for any nonzero origins
      in the PDF coordinates).  The set_of_page_nums_to_crop argument is the set of page
      numbers to crop; it is passed so that unnecessary calculations can be
      skipped.  The argparse_args argument should be passed the args parsed from
      the command line by argparse.  The chosen_PdfFileWriter is the PdfFileWriter
      class from whichever pyPdf package was chosen by the main program.  The
      function returns the list of bounding boxes."""
      global args, page_nums_to_crop, PdfFileWriter
      args = argparse_args # Make args available to all funs in module, as a global.
      page_nums_to_crop = set_of_page_nums_to_crop # Make the set of pages global, too.
      PdfFileWriter = chosen_PdfFileWriter # Be sure correct PdfFileWriter is set.
  
      if args.gsBbox:
          if args.verbose:
              print("\nUsing Ghostscript to calculate the bounding boxes.")
          bbox_list = ex.get_bounding_box_list_ghostscript(input_doc_fname,
                                               args.resX, args.resY, args.fullPageBox)
      else:
          if not hasPIL:
              print("\nError in pdfCropMargins: No version of the PIL package (or a"
                    "\nfork like Pillow) was found.  Either install that Python"
                    "\npackage or use the Ghostscript flag '--gsBbox' (or '-gs') if you"
                    "\nhave Ghostscript installed.", file=sys.stderr)
              ex.cleanup_and_exit(1)
          bbox_list = get_bounding_box_list_render_image(input_doc_fname, input_doc)
  
      # Now we need to use the full page boxes to translate for non-zero origin.
      bbox_list = correct_bounding_box_list_for_nonzero_origin(bbox_list,
                                                               full_page_box_list)
  
      return bbox_list