We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Create ppt from .pot template?

Hi everybody,

- I want to create a ppt file from pot template file. And the following is my code:
DirectoryInfo dir = new DirectoryInfo(".");
string templatePath = dir.Parent.Parent.FullName + “\Author.pot”;
string outputPath = @“C:\Documents and Settings\lqvuong\Desktop\Author_output.ppt”;
try
{
System.IO.FileStream fis = new System.IO.FileStream(templatePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
Presentation pres = new Presentation(fis);
fis.Close();

Slides slides = pres.Slides;
for (int i = 0; i < slides.Count; i++)
{

// Set text for text frames
Shapes shapes = slides[i].Shapes;
Shape s = null;
for (int j = 0; j < shapes.Count; j++)
{
TextFrame tf = null;
s = shapes[j];
tf = shapes[j].TextFrame;
if (tf != null)
{
if (tf.Text.ToLower() == “click to edit master title style”)
{
tf.Paragraphs[0].Portions[0].Text = “Master title inserted here”;
}
else if (tf.Text.ToLower() == “click to edit master subtitle style”)
{
tf.Paragraphs[0].Portions[0].Text = “Master Subtitle inserted here”;
}
else if (tf.Text.ToLower() == “resite recorder”)
{
tf.Paragraphs[0].Portions[0].Text = “resite recorder inserted here”;
}
}
}
}
pres.Save(outputPath, SaveFormat.Ppt);
}
catch (System.Exception ex)
{
System.Console.WriteLine(ex.StackTrace);
}
Result: No error, Author_output.ppt is created but I can’t open it because some part is missing.
But if I just do like this:
DirectoryInfo dir = new DirectoryInfo(".");
string templatePath = dir.Parent.Parent.FullName + “\Author.pot”;
string outputPath = @“C:\Documents and Settings\lqvuong\Desktop\Author_output.ppt”;
try
{
System.IO.FileStream fis = new System.IO.FileStream(templatePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
Presentation pres = new Presentation(fis);
fis.Close();
pres.Save(outputPath, SaveFormat.Ppt);
}
catch (System.Exception ex)
{
System.Console.WriteLine(ex.StackTrace);
}
It’s OK. And of course the generated file is empty.
Can anybody explain what is missing when creating ppt file from pot file? And what is solution?

Thanks and best regards!

Hi Vuong,

I have tried to observed the code snippet shared and it seems to be ok. Can you please share the source presentation file necessary investigation on our end.

Thanks and Regards,

Hi Mudassir,

It’s a pity that I can’t upload/attach any file because of my company policy.
Your answer means that Aspose Slide .net can read .pot file, manipulate with it and then generate to .ppt or .pptx file?

Hi Vuong,

I have tried to observe the issue shared and i feel that you may be trying to compare the default text shown in the text holders of presentation template and comparing them. If this is the case then I have found your issue. There is nothing wrong with the code but difference in understanding. Actually, if no text is added in any of given text holder, it shows the default text for that particular text holder when you view this in PowerPoint. As a matter of fact this default text displayed is just for information purpose but not part of text frame and you are probably comparing on the basis of that. The text frame is in fact empty and when you are doing comparison on the basis of the mentioned text then nothing is done and it is absolutely right behavior. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Now, there are two solutions for this. Either you set some comparison text for every text frame in your template or you may use Shape.AlternativeText property with every text frame. I have generated a sample POT template and have set the text of slide text holders to the ones you are comparing. It’s working absolutely fine. For your reference, I have also shared the POT template as well. Secondly, at the moment PPTX cannot be generated on the basis of POT templates.

Thanks and Regards,