Free Support Forum - aspose.com

Aspose.PDf - Mix text color on same line

Hi, my Customer wants to have a report line similar to this:

thisCompany Report

Is this possible? Have I just missed this in the Help/Demos?

Cheers

Alan

Hi,

The following code will give you desired result:

Pdf pdf1 = new Pdf();

Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

Text text1 = new Text(sec1);

sec1.Paragraphs.Add(text1);

Segment segment1 = text1.Segments.Add("This ");

segment1.TextInfo.Color = new Aspose.Pdf.Color("Red");

Segment segment2 = text1.Segments.Add("Company ");

segment2.TextInfo.Color = new Aspose.Pdf.Color("Blue");

Segment segment3 = text1.Segments.Add("Report");

segment3.TextInfo.Color = new Aspose.Pdf.Color("Black");

pdf1.Save("test.pdf");

Thanks.

Thanks Adeel

That's brilliant!

Alan