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

Free Support Forum - aspose.com

Copying Shapes from Master Slides and Slide Layouts

Hello,

I am trying to copy shapes from one master + layout slides in one presentation to another master + layout slides in another presentation. I am able to get the shapes in the same location (X, Y) co-ordinate as well as text / paragraph. What does not get copied is the TextStyles like Font/Size/Bullet style, etc. Can you please suggest how can I achieve that?

Here’s my code

private Presentation copyShapesInMaster(Presentation srcPres, Presentation applyToPres)
{
    applyToPres.Masters[0].Shapes.Clear();

    foreach (IShape shape in srcPres.Masters[0].Shapes)
    {
        applyToPres.Masters[0].Shapes.AddClone(shape);
    }

    foreach (ILayoutSlide layoutSlide in applyToPres.LayoutSlides)
    {
        layoutSlide.Shapes.Clear();
    }

    foreach (ILayoutSlide layoutSlide in srcPres.LayoutSlides)
    {
        var applyToLayoutSlide = applyToPres.LayoutSlides.GetByType(layoutSlide.LayoutType);

        if (applyToLayoutSlide != null)
        {
            applyToLayoutSlide.ShowMasterShapes = layoutSlide.ShowMasterShapes;

            foreach (IShape shape in layoutSlide.Shapes)
            {
                applyToLayoutSlide.Shapes.AddClone(shape);
            }
        }
    }

    return applyToPres;
}

@Umaima,
Thank you for contacting support.

Please check your results using the latest version of Aspose.Slides if it is possible. If the issue persists, please share and specify the following:

  • input and output presentations demonstrating the problem
  • version of Aspose.Slides you used

You can zip the files and upload them here.