Free Support Forum - aspose.com

TextPortion Color is not cloned properly

After cloning a slide, Information about the text formatting is lost.
This also happens with handmade slides from PowerPoint.

I am using Version v18.7.0
Below a Full Sample which reproduces the Error.

using System;
using System.Drawing;
using System.IO;
using Aspose.Slides;

namespace ErrorSample
{
    class Program
    {
        public static void Main()
        {
            // set your license Pathhere
            var licensePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Aspose.Total.lic");
            var license = new License();
            using (var file = new FileStream(licensePath, FileMode.Open))
            {
                license.SetLicense(file);
            }

            using (var inPres = new Presentation())
            using (var outPres = new Presentation())
            {
                var shape = inPres.Slides[0].Shapes.AddAutoShape(ShapeType.CircularArrow, 1, 1, 1, 1);
                var textFrame = shape.TextFrame;
                textFrame.Text = "Hello World";
                shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.HotPink;

                // has one Shape
                Console.WriteLine(inPres.Slides.Count);

                // should obviously be 'Color [A=255, R=255, G=105, B=180]'
                var inColor = shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color;
                Console.WriteLine(inColor);

                outPres.Slides.RemoveAt(0);
                var slideClone = outPres.Slides.AddClone(inPres.Slides[0]); // this is where the magic happens, or fails to happen in your case

                // has also one Shape
                Console.WriteLine(slideClone.Shapes.Count);

                var autoShape = slideClone.Shapes[0] as AutoShape;
                // is really our 'Hello World' shape
                Console.WriteLine(autoShape.TextFrame.Text);

                var outColor = autoShape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color;
                // this should also be 'Color [A=255, R=255, G=105, B=180]' but is 'Color [A=255, R=0, G=0, B=0]'
                Console.WriteLine(outColor);

                // this should be true
                Console.WriteLine(outColor == inColor);
            }
        }
    }
}

@jvoigtsolyp,

I have worked with sample code shared by you and have been able to observe the issue specified. An issue with ID SLIDESNET-40443 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

The issues you have found earlier (filed as SLIDESNET-40443) have been fixed in this update.

Saw the Ticket-ID in your changelogs. Tested this one with Aspose Slide Net 18.9 with the Codesample above, Still not working, my other Bug I reported is now fixed, so not an issue with my nuget.

@jvoigtsolyp,

We have observed your requirements and like to share that in order properly saving and cloning of fill format colors you need to set FillFormat.FillType:

// Set portion FillType to Solid
shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillType.Solid;

// Set portion SolidFillColor             
shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.HotPink;

ok I edited my code according to your description, a note in your Documentation that the properties are order sensetive and the fact that you have to set the color last in order to work properly would be great.
Thank you for your help.

@jvoigtsolyp,

It’s good to know things are working on your end. Please feel free to share if there is any issue incurring on your end.