Hi,
I am having one business requirement as we need to find Text & replace with custom values in pptx/ppt format.
We are using Aspose.slides 8.3.0.0 for .Net plateform.
But after replacing text with custom values ,text format getting change .We need to maintain formatting of the pptx/ppt after replacement of custom values.
We are using following code
string dataDir = Request.PhysicalApplicationPath + “\Data\”;
//Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation(dataDir + “FindAndReplace.ppt”);
//Slides slides = pres.Slides;
//Accessing a slide using its slide position
int slideCount = pres.Slides.Count;
for (int i = 1; i <= pres.Slides.Count; i++)
{
Slide slide = pres.GetSlideByPosition(i);
int placeholdersCount = slide.Placeholders.Count;
for (int j = 0; j < placeholdersCount; j++)
{
//Accessing the first placeholder in the slide and typecasting it as a text holder
TextHolder th = (TextHolder)slide.Placeholders[j];
//Comparing the text in text holder to find a specific text holder. If the
//text matches then replace the text inside that text holder
th.Text = th.Text.Replace("", System.DateTime.Today.ToShortDateString());
th.Text = th.Text.Replace("", “Motorola”);
th.Text = th.Text.Replace("", “AmSouth/Harbert Plaza”);
th.Text = th.Text.Replace("", “Birmingham”);
th.Text = th.Text.Replace("", “Albama”);
th.Text = th.Text.Replace("", “35203”);
th.Text = th.Text.Replace("", “Allen Border”);
th.Text = th.Text.Replace("", System.DateTime.Today.AddDays(-10).ToShortDateString());
th.Text = th.Text.Replace("", System.DateTime.Today.AddDays(-1).ToShortDateString());
th.Text = th.Text.Replace("", “Max”);
}
}
//Writing the presentation as a PPT file
pres.Write(dataDir + “FindAndReplace out.ppt”);
But after replacing text with custom values ,text format getting change .We need to maintain formatting of the pptx/ppt after replacement of custom values.
Please find attached ppt for your reference.
Your quick response is appreciated in advance.