How do I clone dictionary (implementing undo-function) ?

Q: I want to implement an undo-function in my application. All extra
info is stored in a dictionary Obj, so I thought I'd be able to clone
this Obj, and store that clone in my application. If I want to undo
something, I can just put back the stored Obj and all changes would be
undone. The only problem is, how do I make that clone? It seems
SDFDoc.ImportObj() comes close, but I think this is only for external
Obj's. Can you please give me some advice on this?

A: You could use 'pdftron.SDF.SDFDoc' and 'pdftron.SDF.ObjSet' to keep
a track collections of loose Obj-s. The main difference is that ObjSet
is a bit more lightweight.

To import an object into an SDFDoc you could use SDFDoc.ImportObj().

If you would like to clone objects within the same document you could
create a container object (e.g. an array or dictionary) and then
insert other object into the container. If objects are not shared
(i.e. are not indirect) they will be automatically cloned. For

SDFDoc d;
Obj my_undo_list = d.CreateIndirectArray();

Obj obj1 = my_undo_list.CreateDict();
obj1.PutNumber("My Key", 123);
obj1.PutName("Hello", "World");

... to clone obj1 in my_undo_list: