docs: def apply_crop_list(crop_list, input_doc, page_nums_to_crop,
                                            already_cropped_by_this_program):
      """Apply the crop list to the pages of the input PdfFileReader object."""
  
      if args.restore and not already_cropped_by_this_program:
          print("\nWarning from pdfCropMargins: The Producer string indicates that"
                "\neither this document was not previously cropped by pdfCropMargins"
                "\nor else it was modified by another program after that.  Trying the"
                "\nundo anyway...", file=sys.stderr)
  
      if args.restore and args.verbose:
          print("\nRestoring the document to margins saved for each page in the ArtBox.")
  
      if args.verbose and not args.restore:
          print("\nNew full page sizes after cropping, in PDF format (lbrt):")
  
      # Copy over each page, after modifying the appropriate PDF boxes.
      for page_num in range(input_doc.getNumPages()):
  
          curr_page = input_doc.getPage(page_num)
  
          # Restore any rotation which was originally on the page.
          curr_page.rotateClockwise(curr_page.rotationAngle)
  
          # Only do the restore from ArtBox if '--restore' option was selected.
          if args.restore:
              if not curr_page.artBox:
                  print("\nWarning from pdfCropMargins: Attempting to restore pages from"
                        "\nthe ArtBox in each page, but page", page_num, "has no readable"
                        "\nArtBox.  Leaving that page unchanged.", file=sys.stderr)
                  continue
              curr_page.mediaBox = curr_page.artBox
              curr_page.cropBox = curr_page.artBox
              continue
  
          # Do the save to ArtBox if that option is chosen and Producer is set.
          if not args.noundosave and not already_cropped_by_this_program:
              curr_page.artBox = intersect_boxes(curr_page.mediaBox, curr_page.cropBox)
  
          # Reset the CropBox and MediaBox to their saved original values
          # (which were set in getFullPageBox, in the curr_page object's namespace).
          curr_page.mediaBox = curr_page.originalMediaBox
          curr_page.cropBox = curr_page.originalCropBox
  
          # Copy the original page without further mods if it wasn't in the range
          # selected for cropping.
          if page_num not in page_nums_to_crop:
              continue
  
          # Convert the computed "box to crop to" into a RectangleObject (for pyPdf).
          new_cropped_box = RectangleObject(crop_list[page_num])
  
          if args.verbose:
              print("\t"+str(page_num+1)+"\t", new_cropped_box) # page numbering from 1
  
          if not args.boxesToSet:
              args.boxesToSet = ["m", "c"]
  
          # Now set any boxes which were selected to be set via the --boxesToSet option.
          if "m" in args.boxesToSet: curr_page.mediaBox = new_cropped_box
          if "c" in args.boxesToSet: curr_page.cropBox = new_cropped_box
          if "t" in args.boxesToSet: curr_page.trimBox = new_cropped_box
          if "a" in args.boxesToSet: curr_page.artBox = new_cropped_box
          if "b" in args.boxesToSet: curr_page.bleedBox = new_cropped_box
  
      return