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

Free Support Forum - aspose.com

Retaining slide size while merging multiple presentation

Hi,

I am currently merging two presentation into one destination slide. How can I retain maximum width and height in my destination presentation.

Hi Prasad,

Thanks for inquiring Aspose.Slides.

I have observed your requirements and like to share that you can set the destination presentation slide size with that of source presentation using following sample code before cloning the slides in destination presentation.

presOut.SlideSize.Size = originalPresentation.SlideSize.Size;

The presOut is destination presentation and originalPresentation is source presentation. I hope the shared information will be helpful.

Many Thanks,

Above code will make sure whatever last originalPresentation size is set to presOut but if the first presentation is of bigger size then I want to keep its height and width.

Consider this scenario. I have three presentation
Pres1 with width:10in height: 5in
Pres2 with width:5in height: 10in
Pres3 with width:5in height: 5in

output presentation should have size of width:10in height: 10in

Hi Prasad,

In that case, you need to first check if the width or height of destination presentation slide is less than respective width or height of source presentation then it should change the size of destination presentation. Otherwise, the size of destination presentation is not changed. The following addition to your sample code will serve the purpose.

if(presOut.SlideSize.Size.Width<originalPresentation.SlideSize.Size.Width)

presOut.SlideSize.Size = originalPresentation.SlideSize.Size;

Many Thanks,

Above sample is not working. Can I modify height and width of the presentation individually? Below is the code used to generate the combined presentation and I have attached the input presentations and output combined deck. combined deck should be of size 10in x 13.33in but its taking the last presentation size which is 10in x 5in.

Function:
public static void combinePresentationTest(out byte[] finalPresentation, params byte[][] presentations)
{
// Create presentation object and copy the slide from input presentations
Presentation outPPT = new Presentation();
SlideCollection slds = (SlideCollection)outPPT.Slides;
foreach (var presentationBytes in presentations)
{
Stream stream = new MemoryStream(presentationBytes);
Presentation presentation = new Presentation(stream);
if (outPPT.SlideSize.Size.Width < presentation.SlideSize.Size.Width || outPPT.SlideSize.Size.Height < presentation.SlideSize.Size.Height)
outPPT.SlideSize.Size = presentation.SlideSize.Size;
foreach (var slide in presentation.Slides)
{
slds.AddClone(slide);
}
}

// Remove the first blank slide
slds.RemoveAt(0);

// Save the presentation.
MemoryStream outStream = new MemoryStream();
outPPT.Save(outStream, SaveFormat.Pptx);
finalPresentation = outStream.ToArray();
}

Called: combinePresentationTest(out combinePPT, Deck, Deck5x5, Deck5x10, Deck10x5);

Hi Parasad,


I have observed your comments. Can you please share which Aspose.Slides version you are using on your end. Also please share environment details with us so that we can further investigate to help you out.

Best Regards,

Hi Prasad,

I have observed the sample code as well as presentation files shared by you. First of all, I like to mention that there is single slide size for entire presentation deck. Every slide will have same slide size that is set on presentation level. In attached presentations, every slide bear different slide size in terms of width and height. What I have observed from your requirement is that you want to set the maximum slide width and maximum slide height of all presentation decks separately. I have modified the sample code as per your requirement to achieve the desired slide size. Please try using the attached sample code for your convenience.

Many Thanks,

Thanks. This worked.