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

Free Support Forum - aspose.com

Issue with merging of PPT slides in .Net using Aspose.Slides

Hi,

We have an issue while merging of individual PPT slides in .Net (Framewrok 2.0) using Aspose.Slides. Individual reports are being generated properly from SSRS 2005 by using the DLL Aspose.Slides.ReportingServices.dll(Version 2.1.1.0). But while merging we see the below issue -

Object reference not set to an instance of an object.

However, this issue is not occuring consistently.

Please let us know the solution to the above problem.

The version of the Aspose.Slides DLL which we have used is 2.9.0.0.

Thanks,

Sridevi

Hi Sridevi,

This message appears when you try to merge a slide that does not exist in the individual presentation. It can be avoided using the statement like this:

for(int i=1;i<=pres.Slides.Count;i++)

{

presMerge.CloneSlide(pres.GetSlideByPosition(i),presMerge.Slides.Count);

}

Hi,

Thanks for the reply.

But, we have found that we are getting the exception in the below line while merging the individual PPTs -

if (pre1.SlideSize.Width < pre.SlideSize.Width || pre1.SlideSize.Height < pre.SlideSize.Height)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

{

pre1.SlideSize = pre.SlideSize;

}

The exception is being thrown when the values are as follows -

pre1.SlideSize.Width = 6336

pre.SlideSize.Width = 6336

pre1.SlideSize.Height = 4320

pre.SlideSize.Height = 4896

This exception is occuring in the third iteration for the above values. For the first two iterations, we are not getting exception, the values are as follows -

1st iteration -

pre1.SlideSize.Width = 5760

pre.SlideSize.Width = 6336

pre1.SlideSize.Height = 4320

pre.SlideSize.Height = 4320

2nd iteration -

pre1.SlideSize.Width = 6336

pre.SlideSize.Width = 5760

pre1.SlideSize.Height = 4320

pre.SlideSize.Height = 4320

The following is the piece of code which we are using for the merging purpose -

//Variable declarations

int x=2;

Presentation pre;

FileStream fis1 = null;

string[] objSortedFiles = Directory.GetFiles(@"C:\source\ppts\input");

Presentation pre1 = new Presentation();

foreach (string objFileName in objSortedFiles)

{

fis1 = new System.IO.FileStream(objFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);

pre = new Presentation(fis1);

if (pre1.SlideSize.Width < pre.SlideSize.Width &&

pre1.SlideSize.Height < pre.SlideSize.Height)

{

pre1.SlideSize = pre.SlideSize;

}

SortedList lst = new SortedList();

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

{

Slide si = pre.GetSlideByPosition(i);

pre.CloneSlide(si, x, pre1, lst);

x++;

}

}

pre1.Slides.Remove(pre1.GetSlideByPosition(1));

pre1.Write(@"C:\source\ppts\output\merged.ppt");

-------------------------------------------

Please let me know the solution for this issue.

Thanks,

Sridevi

Hi Sridevi,

I have tested the statement

pre1.SlideSize = pre.SlideSize;

pointed out by you with the following values:

pre1.SlideSize.Width = 6336

pre.SlideSize.Width = 6336

pre1.SlideSize.Height = 4320

pre.SlideSize.Height = 4896

However, no exception thrown.

I think, it would be better, if you provide the effected folder for proper investigation.