Free Support Forum - aspose.com

Set Default Font Size


#1

I am trying to set the Default Font Size for generated Word Documents, but when the document is opened, the Font Size falls back to 12.

I am using the following to set the Font Size and Font Name:

Document document = new Document();
document.CompatibilityOptions.OptimizeFor(Aspose.Words.Settings.MsWordVersion.Word2013);
document.Styles.DefaultFont.Name = 'Arial';
document.Styles.DefaultFont.Size = 36;

The Default Font name applies correctly when the document is opened, but for some reason the Font Size defaults to 12 once the document is opened and not as 36.

Can you please assist me if I am doing something wrong?


#2

@RuanVM,

We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-18553. We will further look into the details of this problem and will keep you updated on the status of the linked issue.


#3

@RuanVM,

Regarding WORDSNET-18553, it is to update you that the specified font size (36) was successfully written by the code at a document default run properties. It does not affect the font size, because style Normal contains explicitly specified font size (12).

To get the desired document, please also specify style Normal font size.
In order to create desired document, please, add this line of code:

document.Styles["Normal"].Font.Size = 36;

Or you can clear Normal style formatting by using the following code

doc.Styles["Normal"].Font.ClearFormatting();

Hope, this helps.