I am evaluating Aspose Powerpoint using version 2.1.2.0 using a very small test class - I have included the code at the bottom of this message. I get a very large number of exceptions raised and apparent caught in the Aspose code. Is this normal, or can I do something about? I feel as if there must something very simple that I have missed!
Here are the details:
I have taken a copy of the supplied file "demo.ppt" and renamed it "TemplateForAspose.ppt" for purpose of this test.
On the following line (full code is below):
Presentation theGen = new Aspose.PowerPoint.Presentation(thePath);
a System.NullReferenceException is raised with the message "Object reference not set to an instance of an object".
The stack trace shows:
Aspose.PowerPoint.MainMaster::.ctor()
Aspose.PowerPoint.Presentation::.ctor()
Aspose.PowerPoint.Presentation::.ctor()
Aspose.PowerPoint.Presentation::.ctor()
PowerPointCSharpTest.SimpleTestX::Execute()
A further 43 identical exceptions are then raised before the constructor exits.
Then on the line:
Aspose.PowerPoint.Slide theSlide = theGen.AddBodySlide();
we get a System.IO.FileNotFoundException with message "No such entry: 'Pictures'". This is followed by about another 40 NullReferenceExceptions apparently identical to the ones described above.
However, the code seems to work: the new slide is added and the trivial change I have coded for does actually take place and can be viewed in the saved file.
__________________________________________________________
public class SimpleTestX
{
public SimpleTestX()
{
//
// TODO: Add constructor logic here
//
}
public void Execute(){
string thePath = HttpContext.Current.Server.MapPath(@"~\TemplateForAspose.ppt");
Presentation theGen = new Aspose.PowerPoint.Presentation(thePath);
string x = "";
Aspose.PowerPoint.Slide theSlide = theGen.AddBodySlide();
for(int i = 0; i < theSlide.Placeholders.Count; i++){
string s = theSlide.Placeholders.PlaceholderType.ToString();
x = x + s;
if (theSlide.Placeholders.PlaceholderType == PlaceholderType.Body){
TextHolder th = theSlide.Placeholders as TextHolder;
th.Paragraphs[0].Portions[0].Text = "This is the replaced text in the body.";
}
}
thePath = HttpContext.Current.Server.MapPath(@"~\ModifiedByAspose.ppt");
theGen.Write(thePath);
}
}
__________________________________________________________
Many thanks for your attention,
Richard Cox.