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

Free Support Forum - aspose.com

How to set font size or color to each word

Hi,

I want to set color or size to each word in a textfield.
Please see attached file(sample.ppt)

To do so, you just need a portion object in the portions collection of paragraph object.

e.g

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Paragraph para=tf.Paragraphs[0];

Portion port=new Portion(para.Portions[0]);

port.Text=”Word2”;

port.FontHeight=32;

port.FontColor=Color.Red;

Note, I earlier gave you example of Formatted Table, you should check it carefully, it has clear example of adding different portions with different colors and font heights.

Thank you for an answer.

But, What I want to do is let a different font coexist in one object(Ellipse, TextFrame).
For example, The fifth charactor from the first charactor makes Red, the ninth charactor from the sixth charactor makes Blue.

Thank you.

Whenever, you will change formatting of the text/character, you will have to add a new portion. For example, if you want to write something like this, where all three characters have different colors, you will add three portions in a single paragraph

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

ABC

The code will look like this.

Portion portA=new Portion(para.Portions[0]);

portA.Text=”A”;

portA.FontColor=Color.Red;

para.Portions.Add(portA);

Portion portB=new Portion(para.Portions[0]);

portB.Text=”B”;

portB.FontColor=Color.Blue;

para.Portions.Add(portB);

Portion portC=new Portion(para.Portions[0]);

portC.Text=”A”;

portC.FontColor=Color.Green;

para.Portions.Add(portC);