An extract of The Code to generate the Master or Template slide is:
public static Aspose.Slides.Slide MasterSlide(Presentation pres)
{
Slide slide = pres.Masters[0];
BPASlideObjectsRG.AchievementImageID = 8;
BPASlideObjectsRG.CountryImageID = 3;
BPASlideObjectsRG.PersonImageID = 5;
BPASlideObjectsRG.RetailerLogoID = 6;
try
{
slide.FollowMasterBackground = false;
slide.Background.FillFormat.ForeColor = Color.Gray;
int slideWidth = slide.Background.Width;
int slideHeight = slide.Background.Height;
BPARectangle rect = new BPARectangle();
Picture pic = new Picture(pres, WebConfigurationManager.AppSettings.Get("RSMLogoPath").ToString() + "RSMLogo.jpg");
int picId = pres.Pictures.Add(pic);
int pictureHeight = pres.Pictures[picId - 1].Image.Height * 2;
int pictureWidth = pres.Pictures[picId - 1].Image.Width * 2;
int pictureFrameWidth = 100;
int pictureFrameHeight = 100;
//Adding picture frame to the slide
PictureFrame rsmlogoFrame = slide.Shapes.AddPictureFrame(picId, pictureFrameWidth, pictureFrameHeight, pictureWidth, pictureHeight);
// Adding the heading line to the slide
Point pointStart = new Point(pictureFrameWidth, pictureFrameHeight + pictureHeight + 100);
Point pointEnd = new Point(slideWidth - 100, pictureFrameHeight + pictureHeight + 100);
Line headingLine = slide.Shapes.AddLine(pointStart, pointEnd);
headingLine.LineFormat.ForeColor = Color.Red;
// Add the Heading Info Layout
short fontHeight = 10;
pic = new Picture(pres, WebConfigurationManager.AppSettings.Get("RSMLogoPath").ToString() + "No Image.JPG");
picId = pres.Pictures.Add(pic);
PictureFrame pictureFrame = slide.Shapes.AddPictureFrame(picId, 2120, 720, 300, 300);
BPASlideObjectsRG.CountryImageFrameID = pictureFrame.ZOrderPosition;
BPASlideObjectsRG.CountryImageID = picId;
}
catch (Exception ex)
{
//Do Something
throw;
}
return slide;
}
The Code used to generate the presentation is:
public void Presentation(String AchievementIDs, String UserID, String UserDomain, String ReportType)
{
// Need to add code here to save the presentation job
BPAPresentationDetails presentationDetails = new BPAPresentationDetails(AchievementIDs, UserID, UserDomain, ReportType, "", "", DateTime.Now.ToLocalTime(), "");
presentationDetails = BPASqlBR.InsertPresentationJob(presentationDetails);
try
{
//Set some values
short fontHeight = 10;
string countryLogoPath = WebConfigurationManager.AppSettings.Get("CountryLogoPath").ToString();
string presentationPath = WebConfigurationManager.AppSettings.Get("PresentationPath").ToString();
string personImagePath = WebConfigurationManager.AppSettings.Get("PersonImagePath");
string retailerLogoPath = WebConfigurationManager.AppSettings.Get("RetailerLogoPath");
//Create the presentation
Presentation pres = new Presentation();
//Create the Master Slide
Slide masterSlide = BPAMasterSlide.MasterSlide(pres);
//Start processing the presentation Job
string[] achievementIDArray = AchievementIDs.Split(',');
int max = achievementIDArray.Length-1;
for (int achievementCount = 0; achievementCount <= max ; achievementCount++)
{
Achievement achievement = new Achievement();
//Retrieve Data from the database
achievement = BPASqlBR.GetAchievement(Convert.ToInt32(achievementIDArray[achievementCount].ToString()));
DataRow aRow = achievement.Tables[0].Rows[0];
//Clone the Master Slide
Slide slide = pres.GetSlideByPosition(pres.Slides.LastSlidePosition);
slide = pres.CloneSlide(slide, pres.Slides.LastSlidePosition + 1);
Picture pic = new Picture(pres, countryLogoPath + aRow["CountryLogoName"].ToString());
int picId = pres.Pictures.Add(pic);
PictureFrame pictureFrame = (PictureFrame) slide.Shapes[BPASlideObjectsRG.CountryImageFrameID];
pictureFrame.PictureId = picId;
// Add the Person photo
if ((aRow["PersonPhotoName"].ToString().Length != 0))
{
pic = new Picture(pres, personImagePath + aRow["PersonPhotoName"].ToString());
picId = pres.Pictures.Add(pic);
pictureFrame = slide.Shapes.AddPictureFrame(picId, rectangle.X + rectangle.Width + 100, rectangle.Y, 300, 300);
}
// Add the retailer logo
if (aRow["RetailerLogo"].ToString().Length != 0)
{
pic = new Picture(pres, retailerLogoPath + aRow["RetailerLogo"].ToString());
picId = pres.Pictures.Add(pic);
pictureFrame = slide.Shapes.AddPictureFrame(picId, slide.Background.Width - 600, 720, 400, 300);
}
}
pres.Write(presentationPath + "\\" + UserDomain + "_" + UserID + "_" + DateTime.Now.ToString("yyyyMMdd") + ".ppt");
}
catch (Exception ex)
{
throw(ex);
}
}
The code highlighted in red is where the error is being generated.