docs: def set_cropped_metadata(input_doc, output_doc, metadata_info):
      """Set the metadata for the output document.  Mostly just copied over, but
      "Producer" has a string appended to indicate that this program modified the
      file.  That allows for the undo operation to make sure that this
      program cropped the file in the first place."""
  
      # Setting metadata with pyPdf requires low-level pyPdf operations, see
      # http://stackoverflow.com/questions/2574676/change-metadata-of-pdf-file-with-pypdf
      if not metadata_info:
          # In case it's null, just set values to empty strings.  This class just holds
          # data temporary in the same format; this is not sent into PyPDF2.
          class MetadataInfo(object):
              author = ""
              creator = ""
              producer = ""
              subject = ""
              title = ""
          metadata_info = MetadataInfo()
  
      output_info_dict = output_doc._info.getObject()
  
      # Check Producer metadata attribute to see if this program cropped document before.
      producer_mod = PRODUCER_MODIFIER
      already_cropped_by_this_program = False
      old_producer_string = metadata_info.producer
      if old_producer_string and old_producer_string.endswith(producer_mod):
          if args.verbose:
              print("\nThe document was already cropped at least once by this program.")
          already_cropped_by_this_program = True
          producer_mod = "" # No need to pile up suffixes each time on Producer.
  
      # Note that all None metadata attributes are currently set to the empty string
      # when passing along the metadata information.
      def st(item):
          if item is None: return ""
          else: return item
  
      output_info_dict.update({
            NameObject("/Author"): createStringObject(st(metadata_info.author)),
            NameObject("/Creator"): createStringObject(st(metadata_info.creator)),
            NameObject("/Producer"): createStringObject(st(metadata_info.producer)
                                                                   + producer_mod),
            NameObject("/Subject"): createStringObject(st(metadata_info.subject)),
            NameObject("/Title"): createStringObject(st(metadata_info.title))
            })
  
      return already_cropped_by_this_program