We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set font scaling?

I wanted to set the font scaling, but it didn’t succeed. I set the scaling to 150% in the test file(testFile.docx), and I set the spacing is expanded by 1.2pt,but I couldn’t get these parameter.by my code,I set p.ParagraphFormat.Style.Font.Scaling = 200; but the font in the output file(output.docx) is not scaled to 200%.

Aspose.Words.Document docc = new Aspose.Words.Document("testFile.docx");
            foreach(Aspose.Words.Paragraph p in docc.FirstSection.Body.Paragraphs )
            {
                double sp;
                int sc;
                sp=p.ParagraphFormat.Style.Font.Spacing;
                sc = p.ParagraphFormat.Style.Font.Scaling;
                p.ParagraphFormat.Style.Font.Spacing = 10;
                p.ParagraphFormat.Style.Font.Scaling = 200;

            }
            docc.Save("output.docx");

testFile.docx (330.4 KB)
output.docx (215.3 KB)

@lovecomputer,
You need to set the font scaling and spacing for each run of text in all paragraphs. Please use the following code to get the desired result.

Document docc = new Document("testFile.docx");
foreach (Paragraph p in docc.FirstSection.Body.Paragraphs)
{
   foreach (Run r in p.Runs)
   {
       r.Font.Spacing = 10;
       r.Font.Scaling = 200;
   }
}
docc.Save("output.docx");

What do these two properties do?What’s the difference between an ParagraphFormat.Style.Font.Scaling and a Run.Font.Spacing in runs?

@lovecomputer,
The Word documents have several levels of text formatting: the runs level, the paragraph level, styles level, themes level and document defaults formatting level.

The ParagraphFormat.Style.Font.Scaling and ParagraphFormat.Style.Font.Spacing properties are responsible for the paragraph’s formatting level. The first run and the third run of your test file have their own direct formatting, so the formatting of paragraphs doesn’t take any effect on them.

Changing of the Run.Font.Spacing and Run.Font.Scaling properties works on the runs formatting level, so it affects on document as you expect in your case.