Free Support Forum - aspose.com

Aspose Word + Font/Size control

Hi there,

Just wondering if anyone would know the best way to set the font and size properties on a document in aspose word?? I am a bit new to this coding thing, and would appreciate any help. Thanks in advance…

Hi,

You can specify font and size only if you are building/adding content to the document using DocumentBuilder class. See DocumentBuilder.Font, it allows to specify Name, Size and many other properties for character formatting.

DocumentBuilder builder = new DocumentBuilder(doc);

//Specify font formatting before adding text.
builder.Font.Size = 16;
builder.Font.Bold = true;
builder.Font.Color = System.Drawing.Color.Blue;
builder.Font.Name = “Arial”;
builder.Underline = Underline.Dash;
builder.Write(“Sample text.”);