Portion Font Modification Not Working

An uncommented version of the code below does compile and does add the portions with the values defined in the Portion("") constructors. Attempting to modify the font attributes such as, pGuidanceTitle.FontColor, compiles and runs but the values are not changed in the resultant PowerPoint file.

This section however allows me to modify the font attributes as well as set the text values. Problem is I need Description, Guidance, and Methodology of Metrics to be bolded and of a larger font than quad1Desc.

para.Text = "Description: " + quad1Desc + " Guidance: " + " Methodology of Metrics: ";
para.Portions[0].FontHeight = 10;
para.Portions[0].FontColor = Color.Black;

I also need to insert a blank line between quad1Desc, Guidance, and Methodology of Metrics.

Assistance with this would be most appreciated.

Thank you.

System.IO.FileStream fis = new System.IO.FileStream(MapPath(".") + "\\qctemp.ppt", System.IO.FileMode.Open, System.IO.FileAccess.Read);

Presentation pres = new Presentation(fis);
fis.Close();

Slides slides = pres.Slides;

/***********************************************************/
/*Grab a set of records and generated a slide for each one.*/
/***********************************************************/

var objActivityTask = DbFactoryHelper.GetSqlTable().fn(parm);
foreach (DataRow dr in objActivityTask.Tables[0].DefaultView.Table.Rows)
{
pres.CloneSlide(slides[1], currentSlide);

for (int j = 0; j < slides[currentSlide].Shapes.Count; j++)
{
var shape = slides[currentSlide].Shapes[j];
if (shape.TextFrame != null)
{
var tf = shape.TextFrame;
var para = tf.Paragraphs[0];
if (para.Text == "pptQuad1Description")
{

/********************************************************************************/
/*Setting each portion title via new Portion("Description: "); does indeed work*/
/*However none of the formatting works. Font is instead Arial 18 black. */
/********************************************************************************/

//para.Text = "";
//var pDescTitle = new Portion("Description: ");
//pDescTitle.FontBold = true;
//pDescTitle.FontColor = Color.White;
//pDescTitle.FontHeight = 16;

//var pDesc = new Portion(quad1Desc);
//pDesc.FontColor = Color.White;
//pDesc.FontHeight = 14;

//var pGuidanceTitle = new Portion("Guidance: ");
//pGuidanceTitle.FontBold = true;
//pGuidanceTitle.FontColor = Color.White;
//pGuidanceTitle.FontHeight = 16;

//var pGuidance = new Portion();
//pGuidance.FontColor = Color.White;
//pGuidance.FontHeight = 14;

//var pMetricsTitle = new Portion("Methodology of Metrics: ");
//pMetricsTitle.FontBold = true;
//pMetricsTitle.FontColor = Color.White;
//pMetricsTitle.FontHeight = 16;

//para.Portions.Add(pDescTitle);
//para.Portions.Add(pDesc);
//para.Portions.Add(pGuidanceTitle);
//para.Portions.Add(pGuidance);
//para.Portions.Add(pMetricsTitle);

/********************************************************************/
/*In this situation both the text and font is as specified. Problem*/
/*is I need to have portions with different fonts. */
/********************************************************************/

para.Text = "Description: " + quad1Desc + " Guidance: " + " Methodology of Metrics: ";
para.Portions[0].FontHeight = 10;
para.Portions[0].FontColor = Color.Black;


/********************************************************************/
/*Tried approaching issue this way and still font is Arial 18 black.*/
/********************************************************************/

//para.Portions[1].FontHeight = 14;
//para.Portions[3].FontHeight = 14;

//para.Portions[0].FontHeight = 16;
//para.Portions[2].FontHeight = 16;
//para.Portions[4].FontHeight = 16;

//para.Portions[0].FontBold = true;
//para.Portions[2].FontBold = true;
//para.Portions[4].FontBold = true;

//para.Portions[0].FontColor = Color.White;
//para.Portions[1].FontColor = Color.White;
//para.Portions[2].FontColor = Color.White;
//para.Portions[3].FontColor = Color.White;
//para.Portions[4].FontColor = Color.White;
}
}
}
currentSlide++;

}

Hello Dear,

Thanks for considering Aspose.Slides.

I have observed the issue mentioned by you and have shared the code snippet that will serve your purpose. I would recommend you to please visit this link to get a little insight about the portions and paragraphs. The portions are port of paragraphs and whenever you change any font related properties of any text inside the portion, they get separated in to different portions. So, if you intend to have different text size, color and other font related properties to text inside paragraph, it need to added in separate portions.The paragraphs are the part of text frames. The paragraphs are separated by line feed or carriage return. Each line is a separate paragraph.So, if you intend to add the text in separate line you need to add the text in portions of separate paragraphs.

Presentation pres = new Presentation("d:\\ppt\\Test.ppt");

Slide slide = pres.Slides[0];

String quad1Desc ="Aspose";

foreach (Aspose.Slides .Shape shp in slide.Shapes)

{

TextFrame tTextFrame = shp.TextFrame;

Portion pDesc = tTextFrame.Paragraphs[0].Portions[0];

pDesc.Text = "Description: ";

pDesc.FontBold = true;

pDesc.FontColor = Color.Red;

pDesc.FontHeight = 16;

Portion pquad1Desc = new Portion(quad1Desc);

tTextFrame.Paragraphs[0].Portions.Add(pquad1Desc);

pquad1Desc.FontHeight = 14;

pquad1Desc.FontItalic = true;

pquad1Desc.FontColor = Color.Orange;

Paragraph pEmptyLine = new Paragraph();

tTextFrame.Paragraphs.Add(pEmptyLine);

pEmptyLine.HasBullet = false;

Paragraph pLine2 = new Paragraph();

Portion pGuidance = new Portion("Guidance :");

pGuidance.FontBold = true;

pGuidance.FontColor = Color.Navy;

pGuidance.FontHeight = 18;

pLine2.Portions.Add(pGuidance);

tTextFrame.Paragraphs.Add(pLine2);

pLine2.HasBullet = false;

Paragraph pLine3 = new Paragraph();

Portion Methodology = new Portion(" Methodology of Metrics: ");

Methodology.FontBold = true;

Methodology.FontColor = Color.Purple ;

Methodology.FontHeight = 22;

pLine3.Portions.Add(Methodology);

tTextFrame.Paragraphs.Add(pLine3);

pLine3.HasBullet = false;

}

pres.Write("D:\\ppt\\Test.ppt");

Thanks and Regards,