This demo uses the DevExpress Word Processing Document API to format document text. You can process the predefined sample file or supply your own document. To do the latter, select Upload a File in the file selection drop-down menu.
Specify the required formatting parameters in the panel below. Use the Format Text and Save as... dropdown button to select the output format, apply changes, and download the result.
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using System.Drawing;
void FormatText(Document document, DocumentRange range, string fontName, float fontSize,
Color foreColor, Color backgroundColor, UnderlineType underline, bool bold, bool italic) {
CharacterProperties cp = document.BeginUpdateCharacters(range);
cp.FontName = fontName;
cp.FontSize = fontSize;
cp.ForeColor = foreColor;
cp.BackColor = backgroundColor;
cp.Underline = underline;
cp.Bold = bold;
cp.Italic = italic;
document.EndUpdateCharacters(cp);
}
void ResetCharacterFormatting(Document document, DocumentRange range, CharacterPropertiesMask resetCharacterProperties) {
CharacterProperties cp = document.BeginUpdateCharacters(range);
cp.Reset(resetCharacterProperties);
document.EndUpdateCharacters(cp);
}