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++;
}