none
Theme (Background Images) validation from PPT slides RRS feed

  • Question

  • Hello

    I have a ppt file with different  and same background images . I need to export the same background images  at once and different background images from different name  .. so How to validate the background images  programmatically(c#)  and export as a png file..please respond me asap

    kind regards 

    Gangadhar

    Tuesday, April 26, 2016 6:38 AM

Answers

  • >>>I have a ppt file with different  and same background images . I need to export the same background images  at once and different background images from different name  .. so How to validate the background images  programmatically(c#)  and export as a png file..please respond me asap<<<

    According to your description, I suggest that you could use Open XML SDK 2.5 to iterate over all ImagePart's of a SlidePart, then export as a png file, refer to below code:
    using (PresentationDocument presentationDocument = PresentationDocument.Open("D:\\BackImage.pptx", false))
    {
        PresentationPart presentationPart = presentationDocument.PresentationPart;
    
        Presentation presentation = presentationPart.Presentation;
    
        if (presentation.SlideIdList != null)
        {
            foreach (var slideId in presentation.SlideIdList.Elements<SlideId>())
            {
                SlidePart slidePart = presentationPart.GetPartById(slideId.RelationshipId) as SlidePart;
    
                Console.WriteLine(slidePart.ImageParts.First().Uri);
                ImagePart imagePart = slidePart.ImageParts.First();
    
                // GetStream() returns the image data
                System.Drawing.Image img = System.Drawing.Image.FromStream(imagePart.GetStream());
    
                // You could save the image to disk using the System.Drawing.Image class
                img.Save(@"D:\tempexport.png"); 
            }
        }
    }

    For more information, click here to refer about Working with PresentationML documents (Open XML SDK)
    Wednesday, April 27, 2016 5:30 AM