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

Free Support Forum - aspose.com

Clone PPTX does not retain layout/master?

pres pptx is saved and contains 4 slides that look perfect. I then create a clone in destPres. I then tried code from your online help file to move the master from pres to destPres so it would have the same styles/look and feel; however an empty slide shows up as slide 0 and the slide I tried to insert is there; however the formatting is off, looks like the master code did not work. How do I remove the dummy slide and keep the formatting from the original pres pptx ?

  Dim the_path As String = Path.Combine(Request.PhysicalApplicationPath, "Files\"), iSlide As Integer = 0

            'save our modified pptx
            pres.Save(the_path & ApiKey & ".pptx", Export.SaveFormat.Pptx)

            'based on the modified pptx clone each slide and save as new ppt's
            Using presentation As New Presentation(Path.Combine(Request.PhysicalApplicationPath, "Files\" & ApiKey & ".pptx"))

                Using destPres As New Presentation()

                    ' Instantiate ISlide from the collection of slides in source presentation along with
                    ' master slide
                    Dim SourceSlide As ISlide = pres.Slides(0)
                    Dim SourceMaster As IMasterSlide = SourceSlide.LayoutSlide.MasterSlide

                    ' Clone the desired master slide from the source presentation to the collection of masters in the
                    ' destination presentation
                    Dim masters As IMasterSlideCollection = destPres.Masters
                    Dim DestMaster As IMasterSlide = SourceSlide.LayoutSlide.MasterSlide

                    ' Clone the desired master slide from the source presentation to the collection of masters in the
                    ' destination presentation
                    Dim aSlide As IMasterSlide = masters.AddClone(SourceMaster)

                    ' Clone the desired slide from the source presentation with the desired master to the end of the
                    ' Collection of slides in the destination presentation
                    Dim slds As ISlideCollection = destPres.Slides
                    slds.AddClone(SourceSlide, aSlide, True)

                    ' Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation
                    'slds.AddClone(pres.Slides(0))

                    'remove first default slide from cloned presentation
                    'destPres.Slides.Remove(slds.Item(0))

                    ' Write the destination presentation to disk
                    destPres.Save(the_path & ApiKey & "_" & iSlide & ".pptx", Export.SaveFormat.Pptx)
                End Using

            End Using

@eformx3,

I have observed your requirement. Actually, when you create a default presentation object it creates a default slide at index 0. So you need to remove the default slides in dest presentation before saving using following code.

'remove first default slide from cloned presentation
 destPres.Slides.Remove(slds.Item(0))

Also, when you try following code, it clones slide from source presentation with same master from source presentation.

slds.AddClone(SourceSlide, aSlide, True)

Still doesn’t work…Not sure if I was supposed to remove all the master stuff, tried it with it in and then without as shown below and I get the one slide in the deck which is good; but the layout was not transferred from the original presentation. This is what I have…

Using presentation As New Presentation(Path.Combine(Request.PhysicalApplicationPath, "Files\" & ApiKey & ".pptx"))

                Using destPres As New Presentation()

                    ' Collection of slides in the destination presentation
                    Dim slds As ISlideCollection = destPres.Slides

                    'remove first default slide from cloned presentation
                    destPres.Slides.Remove(slds.Item(0))

                    ' Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation
                    slds.AddClone(presentation.Slides(0))

                    ' Write the destination presentation to disk
                    destPres.Save(the_path & ApiKey & "_" & iSlide & ".pptx", Export.SaveFormat.Pptx)
                End Using

            End Using

I can see the master slides/layouts in the new deck. The slide is too small for the content. Not sure if its a master not being applied or a size thing. I have attached the presentation (source) and destPres deck (target).

decks.zip (122.1 KB)

@eformx3,

I have worked with source code and presentation file shared by you using Aspose.Slides for .NET 17.9 and have been able to observe the issue. A ticket with ID SLIDESNET-39455 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with issue so that you may be automatically notified once issue will be fixed.

What is the average turnaround time?

@eformx3,

I have observed your comments. I like to inform that usually it depends on type and complexity of issue. I have also requested our product team to share further feedback regarding this issue. I request for your patience until further feedback is shared by our product team.

@eformx3,

I suggest you to please try using following sample code on your end. Please share your feedback if this suffice needs on your end.

Public Shared Sub TestCloneIssue()
	Dim path As [String] = "C:\Aspose Data\decks\"
	Using presentation As New Presentation(path + "source.pptx")

		Using destPres As New Presentation()

			' Collection of slides in the destination presentation
			Dim slds As ISlideCollection = destPres.Slides

			destPres.SlideSize.SetSize(presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height, SlideSizeScaleType.DoNotScale)
			'remove first default slide from cloned presentation
			destPres.Slides.Remove(slds(0))

			' Clone the desired slide from the source presentation to the end of the collection of slides in destination presentation
			slds.AddClone(presentation.Slides(0))

			' Write the destination presentation to disk
			destPres.Save(path + "cloned.pptx", Aspose.Slides.Export.SaveFormat.Pptx)

		End Using
	End Using

End Sub

Thanks! That Works!