//// This code is part of Document Solutions for Word demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.Drawing;usingGrapeCity.Documents.Word; namespaceDsWordWeb.Demos{// This sample demonstrates how to add building blocks to a document's glossary.publicclassGlossaryDoc {publicGcWordDocumentCreateDocx() {var doc = newGcWordDocument(); doc.Body.Paragraphs.Add("This sample demonstrates adding building blocks (custom headers and footers in this case) " +"to the document's glossary. They do not show in the generated document. To use the building blocks, " +"open the document in MS Word and explore the document's glossary."); // Add header and footer building blocks to the document's glossary:AddHeaderBuildingBlockToGlossary(doc);AddFooterBuildingBlockToGlossary(doc); // Now the document has two building blocks in the glossary.// Note that when the document is loaded into MS Word, they will not be visible.// To use them, open the document in MS Word and explore the document glossary.return doc; } // Add header building block:privatevoidAddHeaderBuildingBlockToGlossary(GcWordDocument doc) {GlossaryDocument glossary = doc.GlossaryDocument;BuildingBlockCollection buildingBlocks = glossary.BuildingBlocks;BuildingBlock buildingBlock = buildingBlocks.Add("New cool header", "2019 collection", BuildingBlockGallery.CustomHeaders);var bbBody = buildingBlock.Body;//here we can modify body as we wantvar p = bbBody.Paragraphs.Add("New cool building block neader"); p.Style.Font.Color.RGB = Color.Blue; } // Add footer building block:privatevoidAddFooterBuildingBlockToGlossary(GcWordDocument doc) {GlossaryDocument glossary = doc.GlossaryDocument;BuildingBlockCollection buildingBlocks = glossary.BuildingBlocks;BuildingBlock buildingBlock = buildingBlocks.Add("New cool footer", "2019 collection", BuildingBlockGallery.CustomFooter);var bbBody = buildingBlock.Body;// Here we can modify the body as we want:var p = bbBody.Paragraphs.Add("New cool building block footer"); p.Style.Font.Color.RGB = Color.Pink; } }}