Imagery gets lost when deploying to another server

I created a simple demo (web) application to show the possibilities of Aspose.Slides to some sales people.

When I run the application locally, everything works fine.

When I run the application on a remote server (http://vintage.stage.vintage.be/pptgen/) however, all layout and images that are in the original PPT (see http://vintage.stage.vintage.be/pptgen/vintage.ppt) are lost for some reason.

This is the code I use:

System.IO.FileStream fis = new System.IO.FileStream(MapPath(".") + “\vintage.ppt”, 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++)

{

Placeholders pholders = slides[i].Placeholders;

for (int j=0; j<pholders.Count; j++)

{

TextHolder th = pholders[j] as TextHolder;

if (th != null)

{

if (th.Text == “TITLE”)

th.Paragraphs[0].Portions[0].Text = txtPresentationTitle.Text;

else if (th.Text == “SLIDETITLE”)

th.Paragraphs[0].Portions[0].Text = txtSlideTitle.Text;

else if (th.Text.IndexOf(“CONTENT”) != -1)

{

string [] strParagraphs = txtSlideCOntent.Text.Split((char)13);

int iRec = 0;

foreach(string s in strParagraphs)

{

th.Paragraphs[iRec].Portions[0].Text = s.Replace("\n","");

iRec++;

}

}

}

}

}

this.Response.ContentType = “application/vnd.ms-powerpoint”;

this.Response.AppendHeader(“Content-Disposition”, “attachment; filename=demoppt.pps”);

this.Response.Flush();

System.IO.Stream st = this.Response.OutputStream;

pres.Write(st);

this.Response.End();

Do you have any clue?

Dear Maarten,
Thank you for using Apose.Slides.

You should not use Slides.Count as a terminating condition in a for loop, instead use Slides.LastSlidePosition

Also change i=0 to i=1 because slide position is always greater than 0.

Now your code will look like this

for (int i = 1; i <= slides.LastSlidePosition; i++) {
    Slide sld = pres.getSlideByPosition(i);
    Placeholders pholders = sld.Placeholders;
    // ...
}

Hi,

Thanks a lot for your fast answer.

However, I think I need to disagree.

I program in C#, and think some methods are unavailable then (or named differently).
getSlideByPosition() for example can't be found.

I tried to do what you said, but have the exact same problem.
My code is now :

for(int i=1; i<=slides.LastSlidePosition; i++)

{

Placeholders pholders = slides[i].Placeholders;

for (int j=0; j<pholders.Count; j++)

{

This again works fine locally but not on a remote server ..

Actually, I meant to use Presentation.GetSlideByPosition method.

Presentation.Slides collection not only contains normal slides but also contains title masters. So in order to retrieve normal slides by position. Aspose.Slides provides Presentation.GetSlideByPosition method.

Likewise, you cannot use Presentation.Slides.Count property, you must use Presentation.Slides.LastSlidePosition property to get the number of normal slides in the presentation.

My code is now:

System.IO.FileStream fis = new System.IO.FileStream(MapPath(".") + "\\vintage.ppt", System.IO.FileMode.Open, System.IO.FileAccess.Read);

Presentation pres = new Presentation(fis);

fis.Close();

Slides slides = pres.Slides;

for(int i=1; i<=slides.LastSlidePosition; i++)

{

Slide sld= pres.GetSlideByPosition(i);

Placeholders pholders=sld.Placeholders;

However, the exact same problem occurs.
Also, I don't really understand how your solution would have solved the fact that it works locally but not on a remote server ... If my code was wrong, it would have given a wrong output locally as well, no?

Thanks for looking into this.

What versions of Aspose.Slides you use on the remote server?
It looks like you use old Aspose.Slides or something wrong with server settings.
Probably server doesn’t allow .Net read metafiles because of some security settings.
So if you use latest Aspose.Slides then check your server settings.

I only downloaded Aspose.Slides last Friday, so I assume to be using the last version.

As a test case, I tried to deploy my test application to another server. This version works fine (including the images).

However, I'm very sure that there are no "strange" settings on my first server. Do you have any idea what setting it might be on that server that causes this behaviour?

Sorry, I never had such problems and can’t give you any ideas why it can happen.
Actually, the problem is very simple. .Net framework doesn’t want to read metafiles on the server.
I think you can check security settings, try to reinstall .Net framework and GDI+.

When I have some spare time, I will play around with the security settings to find out a possible cause and will keep you posted. However, I'm pretty sure that there are no "strange" settings on that server, since numereous applications already run on it for several years without major problems.

Thanks anyway for the fast responses!