void ClearPages() { // now set up list of current pages int i = 0; Pages pgs = document.Pages; foreach (Page page in pgs) { pages.Add(new GuidePage(this, page, i)); for (int tf = page.TextFrames.Count; tf > 0; tf--) { TextFrame textFrame = (TextFrame)page.TextFrames[tf]; bool del = true; if (textFrame.Paragraphs.Count > 0) { Paragraph p = (Paragraph)textFrame.Paragraphs[1]; ParagraphStyle ps = (ParagraphStyle)p.AppliedParagraphStyle; if (ps.Name == "hiddenToc0") { del = false; } } if (del) { textFrame.Delete(); } } for (int tf = page.Rectangles.Count; tf > 0; tf--) { Rectangle rect = (Rectangle)page.Rectangles[tf]; rect.Delete(); } i++; } }