On OpenXmlDeveloper.org, in one of the forums, there is a thread about how to clean Word proofing errors clutter out of an Open XML WordprocessingML document. In PowerTools, in the HtmlConverter project, there is a class called MarkupSimplifier, which can remove proofing errors. In addition, it can simplify WordprocessingML markup in a variety of ways, including removal of comments, content controls, and etc. The blog post, Enabling Better Transformations by Simplifying Open XML WordprocessingML Markup describes MarkupSimplifier in more detail.
Here is a small screen-cast that shows the use of MarkupSimplifier. In the screen-cast, I use Open XML Package Editor Power Tool for Visual Studio 2010.
Walks through the process of downloading and compiling a sample for MarkupSimplifier.
Here is the listing of the small program that uses MarkupSimplifier
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenXmlPowerTools;
using DocumentFormat.OpenXml.Packaging;
class Program
{
static void Main(string[] args)
{
using (WordprocessingDocument doc =
WordprocessingDocument.Open("Test.docx", true))
{
SimplifyMarkupSettings settings = new SimplifyMarkupSettings
{
RemoveComments = true,
RemoveContentControls = true,
RemoveEndAndFootNotes = true,
RemoveFieldCodes = false,
RemoveLastRenderedPageBreak = true,
RemovePermissions = true,
RemoveProof = true,
RemoveRsidInfo = true,
RemoveSmartTags = true,
RemoveSoftHyphens = true,
ReplaceTabsWithSpaces = true,
};
MarkupSimplifier.SimplifyMarkup(doc, settings);
}
}
}