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

Free Support Forum - aspose.com

Added line behind text

I am having a problem where there is a line added behind a couple of my text boxes on the generated slide after cloning. Can someone help me. I have attached one of the slides of each of the source and generated ppt’s. One thing I do know is that it is not using the correct master slide as you can tell from the attachments, but I don’t know why that would cause this problem.

Dear Daniel,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have cloned your slide and could not reproduce the problem you stated. Please see the output of the following code

Presentation srcPres = new Presentation(@"D:\downloads\hensods\source.ppt");

Presentation dstPres = new Presentation();

dstPres.SlideSize = srcPres.SlideSize;

SortedList idList = new SortedList();

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

{

Slide srcSld = srcPres.GetSlideByPosition(i);

Slide dstSld = srcPres.CloneSlide(srcSld, i, dstPres, idList);

}

dstPres.Write(@"c:\out.ppt");

You wouldn’t get the same problem, because that is only one slide out of a huge 200+ presentation. We are taking about 10 different presentations and putting them together into one. Here is my code:



static void addAllSlides(List orders, Dictionary ordermap)

{

SortedList sortedList = new SortedList();

foreach (int order in orders)

{

SPFile file = ordermap[order];



// Read the file into a byte array

byte[] b = file.OpenBinary();



Presentation src = null;



try

{

// Read the powerpoint into Aspose

src = new Presentation(new MemoryStream(b));

}

catch (Exception e) { d("Reading source: " + e.ToString()); }

// Copy all of the slides into the destination powerpoint

int numslides = src.Slides.LastSlidePosition;



for (int i = 1; i
{



Slide slide = src.CloneSlide(src.GetSlideByPosition(i), dst.Slides.LastSlidePosition + 1, dst, sortedList);

if (i == 1 && !slideID.ContainsKey(order))

slideID.Add(order, slide.SlideId);

}

GC.Collect();

}

}

Hello Daniel,
You shouldn’t use the same sortedlist for all presentations, each pair {src, dst} has to have its own sortedlist. Though I’m not sure this is the source of you problem.

I had it like that for a while and I had the problem with too many master slides. Here is your quote to fix that:



Dear Daniel,

Aspose.Slides tries to minimize a number of cloned masters, but it needs caller’s cooperation. Please check the “idList” parameter of the CloneSlide method, it stores information about already cloned masters. If you will pass the same sortedlist for every source and target presentation pair, there will be much lesser unnecessary masters.

Nikolay Kuzmin



I changed it to what you see now because of that. I do see that you say to pass a new one for each pair, but it signifigantly changed the amount of master slides, so I assumes that it was working. All of my source files have a lot of the same master slides in them.

Every pair {SourcePresentation; TargetPresentation} must to have its own sortedList.
If you have used one sortedlist object to clone slides from pres1 to pres2, you cannot use that sortedlist object to clone slides from pres1 to pres3 or from pres3 to pres2 or even from pres2 to pres1, only with same pair and direction (pres1 to pres2). To clone slide from/to other presentations you must create new sortedlist for each case.
In your case, you’re changing source presentation, so you have to change sortedlists too. All you need is to move sortedlist creation into the cycle:

static void addAllSlides(List orders, Dictionary ordermap)
{
foreach (int order in orders)
{
SPFile file = ordermap[order];

// Read the file into a byte array
byte[] b = file.OpenBinary();

Presentation src = null;

try
{
// Read the powerpoint into Aspose
src = new Presentation(new MemoryStream(b));
SortedList sortedList = new SortedList();
}
catch (Exception e) { d("Reading source: " + e.ToString()); }
// Copy all of the slides into the destination powerpoint
int numslides = src.Slides.LastSlidePosition;

for (int i = 1; i
{

Slide slide = src.CloneSlide(src.GetSlideByPosition(i), dst.Slides.LastSlidePosition + 1, dst, sortedList);
if (i == 1 && !slideID.ContainsKey(order))
slideID.Add(order, slide.SlideId);
}
GC.Collect();
}
}

I will try that, but then I will go back to another problem that I had with about 145 master slides. This change brought it down to less than 20.