DeleteHeaderFooterShapes
Section.DeleteHeaderFooterShapes method
从本节的页眉和页脚中删除所有形状(绘图对象)。
public void DeleteHeaderFooterShapes()
例子
展示如何从某个部分的所有页眉页脚中删除所有形状。
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// 创建具有形状的主标题。
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.InsertShape(ShapeType.Rectangle, 100, 100);
// 创建带有图像的主要页脚。
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.InsertImage(ImageDir + "Logo icon.ico");
Assert.AreEqual(1, doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderPrimary].GetChildNodes(NodeType.Shape, true).Count);
Assert.AreEqual(1, doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary].GetChildNodes(NodeType.Shape, true).Count);
// 从第一部分的页眉和页脚中删除所有形状。
doc.FirstSection.DeleteHeaderFooterShapes();
Assert.AreEqual(0, doc.FirstSection.HeadersFooters[HeaderFooterType.HeaderPrimary].GetChildNodes(NodeType.Shape, true).Count);
Assert.AreEqual(0, doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary].GetChildNodes(NodeType.Shape, true).Count);
也可以看看
- class Section
- 命名空间 Aspose.Words
- 部件 Aspose.Words