using (PDFDoc doc = new PDFDoc(filepath))
{
doc.InitSecurityHandler();
Config config = doc.GetOCGConfig();
Obj ocgs = doc.GetOCGs();
if (ocgs == null) return;
int ocg_sz = ocgs.Size();
for(int i = 0; i < ocg_sz; ++i) {
Obj ocg = ocgs.GetAt(i);
Group group = new Group(ocg);
string ocg_name = group.GetName();
Console.WriteLine(ocg_name);
if (ocg_name == layer_to_turn_off) group.SetInitialState(config, false);
}
doc.Save(outfilepath, SDFDoc.SaveOptions.e_linearized);
}