Reputation: 4094
Recenty I am using Aspose Word to generating some reports, and there is a small problem.
Currently I am using DocumentBuilder
and a 2-column table to make up the footer, System name at first column align to left while page number at second column align to right.
Everything is fine, yet I do not want the footer looks so dull as plain text, so I would like to add some style to the footer.
I would like to apply some built-in template of footer, say Alphabet as shown below, is it possible to do so by using Aspose Word?
Upvotes: 0
Views: 724
Reputation: 1090
If you have MS Word 2013 installed on your machine, you'll most likely find a Word document 'Built-In Building Blocks.dotx' at the following location:
C:\Users\Awais\AppData\Roaming\Microsoft\Document Building Blocks\1033\15\Built-In Building Blocks.dotx
The predefined built-in building blocks entries that ship with Word are stored in above template document. Using Aspose.Words, you can extract any building block from it and paste inside another Word document.
GlossaryDocument class in Aspose.Words represents such Building Blocks. Please try using the following code:
Document docBuildingBlocks = new Document(MyDir + @"Building Blocks.dotx");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
GlossaryDocument glossaryDocument = docBuildingBlocks.GlossaryDocument;
foreach (BuildingBlock buildingBlock in glossaryDocument.BuildingBlocks)
{
if (buildingBlock.Gallery.ToString().StartsWith("Footer") &&
buildingBlock.Name.Equals("ViewMaster (Vertical)"))
{
Section sec = (Section)buildingBlock.FirstChild;
foreach (Node node in sec.Body.ChildNodes)
{
HeaderFooter hf = doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary];
hf.AppendChild(doc.ImportNode(node, true));
}
}
}
doc.Save(MyDir + @"15.6.0.docx");
Hope, this helps.
I work with Aspose as Developer Evangelist.
Upvotes: 1