Copying shape fill color

Last post 01-12-2011, 11:00 PM by Yasiduy3k. 6 replies.
Sort Posts: Previous Next
  •  01-11-2011, 11:26 AM 277750

    Copying shape fill color .NET

    Attachment: Present (inaccessible)

    Hi,

    We’ve been trying to include a customized number formatting for slide number of a Powerpoint 2007 presentation using Aspose.Slides for .NET 4.2.0.

    This is the scenario:

    We have a .pptx file which have five slides with each slide having just a a text box with letters “BBB” and slide number ranging from 1 to 5. (Font-color gray, no border, background-color- white PS: This will vary according to each .pptx file.)

    We want to format only the slide number to display a text such as: ‘1 of 5’, ‘2 of 5’, etc for the relevant slide.

    What we’re doing presently is reading through each- slide shape to get the shape that has a value equals to the slide position. Then get its dimensions, placement and formatting, and assign it to a rectangular shape which I create to hold the customized formatting. Finally hide the existing page number.

    So far we have been successfully able to create the rectangular shape, enter the font style and formatted page number.

    But we are unable to get the exact fill-color, font-color and remove the border of the rectangle according to the exsisting.

    Please refer the attached code snippet and the exsisting powerpoint.

     

    I have referred the following links but without any success,

    http://www.aspose.com/documentation/.net-components/aspose.slides-for-.net/formatting-lines-of-the-shapes-1.html

    http://www.aspose.com/documentation/.net-components/aspose.slides-for-.net/managing-multiple-paragraphs-with-multiple-portions-1.html

     Also when I try to access font-color property from ShapeStyle, in the existing presentation it returns a null value exception!!!

     Awaiting for your suggestions.

    Thanks,

    Yasindu.

     

     

     
  •  01-12-2011, 1:59 AM 277887 in reply to 277750

    Re: Copying shape fill color

    Hi,

    I've discovered something related to aspose and settings slide numbers for .pptx.

    For an example, if I create 2 slides and enable slide number from the powerpoint, when I read the shape related to the slide number, within coding i get the following properties as not defined!!!

    ashp.FillFormat.FillType;

    ashp.LineFormat.FillFormat.FillType

    And for the following I get a default color of ARGB:255,0,0,0

    ashp.TextFrame.Paragraphs[0].Portions[0].FillFormat.SolidFillColor.Color;

    ashp.FillFormat.SolidFillColor.Color;

    ashp.LineFormat.FillFormat.SolidFillColor.Color;

    But If I manually format any of the shapes in the original .pptx file(autoshape and its text that holds the slide number) by right clicking -> Format Autoshape

    Then Aspose reads the related values according to that formatting, and gives me the correct output.

    Still  Awaiting for your suggestions.

    Thanks,

    Yasindu.

     
  •  01-12-2011, 3:41 AM 277917 in reply to 277887

    Re: Copying shape fill color

    Hi Yasindu,

    I like to share
    following code snippet, I hope this will help you.

            PresentationEx pres = new PresentationEx(@"d:\pptx\SlideNumbers.pptx");

            foreach (SlideEx sld in pres.Slides)
            {
                int idx = sld.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 10, 75, 150, 50);
                AutoShapeEx ashp = (AutoShapeEx)sld.Shapes[idx];
                ashp.AddTextFrame(sld.SlideNumber + " of " + pres.Slides.Count);
                ashp.TextFrame.Paragraphs[0].Portions[0].FillFormat.FillType = FillTypeEx.Solid;
                ashp.TextFrame.Paragraphs[0].Portions[0].FillFormat.SolidFillColor.Color = Color.Black;
                ashp.LineFormat.Width = Convert.ToDouble(3.5);
            }
            pres.Write("d:\\pptx\\SlideNumbers.pptx");

            PresentationEx pres2 = new PresentationEx(@"d:\pptx\SlideNumbers.pptx");
            foreach (SlideEx sld in pres2.Slides)
            {
                foreach (AutoShapeEx sh in sld.Shapes)
                {
                    //remove border of shape
                    sh.LineFormat.Width =Convert.ToDouble(0.00);

                    //Get Fill color of the shape
                    Color clr = sh.FillFormat.SolidFillColor.Color;
                    Int16 A = clr.A;
                    Int16 R = clr.R;
                    Int32 G = clr.G;
                    Int32 B = clr.B;

                    sh.TextFrame.Paragraphs[0].Portions[0].FillFormat.SolidFillColor.Color = Color.White;

                    //Get text color
                    Color clrtext = sh.TextFrame.Paragraphs[0].Portions[0].FillFormat.SolidFillColor.Color;

                    A = clrtext.A;
                    R = clrtext.R;
                    G = clrtext.G;
                    B = clrtext.B;
                   
                }
            }

            pres2.Write("d:\\pptx\\SlideNumbers.pptx");

    Regards,
    Tahir Manzoor

    Best Regards,
    Tahir Manzoor
    Support Developer, Aspose Sialkot Team
    http://www.aspose.com
    Your File Format Experts
    Keep in touch! We're on Twitter and Facebook
     
  •  01-12-2011, 4:31 AM 277933 in reply to 277917

    Re: Copying shape fill color .NET

    Attachment: Present (inaccessible)

    Hi,

    Thanks for the quick reply, but this is not what I was looking for.

    I have attached a sample project as AsposePPTX2.rar. The Powerpoint file I'mm reffering is included in the bin folder.

    Awaiting for your suggestions,


    Thanks,
    Yasindu.

     

     
  •  01-12-2011, 5:27 AM 277944 in reply to 277933

    Re: Copying shape fill color

    Attachment: Present (inaccessible)

    Hi Yasindu,

    I have been working on the issue shared by you yesterday night. Please use the code snippet shared in the attachment for your purpose. Hopefully, it will be valuable for you.

    Thanks and Regards,


    Mudassir Fayyaz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
  •  01-12-2011, 7:54 AM 277970 in reply to 277933

    Re: Copying shape fill color

    Attachment: Present (inaccessible)

    Hello Dear,

    FYI, I have used Alternative Text property of the shape for the shape identification instead of comparing the inside text. I have attached the modified presentation for your reference, that contains the Aleternative Text property for the slide number shape, you are working with. The observation about some of properties showing undefined values by you are right and an issue with ID 23141 has been created in our issue tracking system. This thread has also been linked with the issue, so that you may be automatically notified, once the issue is resolved.

    We are sorry for your inconvenience,


    Mudassir Fayyaz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
  •  01-12-2011, 11:00 PM 278130 in reply to 277944

    Re: Copying shape fill color

    Thanks Mudassir for your quick and invaluable support.

    Regards,

    Yasindu.

     
View as RSS news feed in XML