Flatten all OCG Layers

I am not sure what precisely you would like to do, but would

pdfdoc.GetRoot().Erase(“OCProperties”);

work for you?