//
// This code is part of Document Solutions for Word demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using GrapeCity.Documents.Word;
namespace DsWordWeb.Demos
{
// This sample loads an existing DOCX and modifies
// some of the built-in styles.
public class ModifyFormat
{
public GcWordDocument CreateDocx()
{
var doc = new GcWordDocument();
// Load an existing DOCX file:
var path = Path.Combine("Resources", "WordDocs", "JsFrameworkExcerpt.docx");
doc.Load(path);
// Modify the title and sub-title styles:
doc.Styles[BuiltInStyleId.Title].ParagraphFormat.Shading.BackgroundPatternColor.RGB = Color.PaleGoldenrod;
doc.Styles[BuiltInStyleId.Title].Font.Color.RGB = Color.OrangeRed;
doc.Styles[BuiltInStyleId.Subtitle].Font.Color.RGB = Color.MediumVioletRed;
doc.Styles[BuiltInStyleId.Subtitle].Font.Italic = true;
// Modify the top 4 heading styles:
var headings = new List<Style>
{
doc.Styles[BuiltInStyleId.Heading1],
doc.Styles[BuiltInStyleId.Heading2],
doc.Styles[BuiltInStyleId.Heading3],
doc.Styles[BuiltInStyleId.Heading4],
};
foreach (var heading in headings)
{
heading.Font.Color.RGB = Color.Blue;
heading.Font.Bold = true;
heading.Font.Italic = true;
}
// Done:
return doc;
}
}
}