def group_obj_into_stream(doc: Doc , env_num: int = None, o_nums: set = None):
    """Provision a ObjStm object and tag all changes to target this envelope."""
    if not env_num:
        new_doc, iref = add_object(doc, b'')
        env_num = int(iref.imag)
    else:
        new_doc = copy_doc(doc, revision='SAME')
    current = new_doc.index[-1]
    if not o_nums:
        chgs = changes(doc)
        o_nums = set([int(iref.imag) for iref, _ in chgs])
    for o in o_nums:
        x = new_doc.obj(o)
        if type(x) == Stream:
            continue
        elif type(x) == dict and 'Length' in x:
            continue
        elif current[o]['o_gen'] != 0:
            continue
        # TODO Add another elif for encryption dict
        current[o]['env_num'] = env_num
    new_doc.cache[env_num] = Stream({'/Type': '/ObjStm'}, b'', b'')
    return new_doc
Provision a ObjStm object and tag all changes to target this envelope.
pdfsyntax/docstruct.py