wordpress hit counter
openxml and powerpoint doubt - Open XML SDK 2.0 - Development Tools - OpenXML Developer

openxml and powerpoint doubt

Development Tools

Discussions about working with Open XML using a wide range of development tools

openxml and powerpoint doubt

  • rated by 0 users
  • This post has 5 Replies |
  • 3 Followers
  • i am working on modifying powerpoint presentations using openxml

    i m currently stuck in identifying if it is possible to add a bulleted point to

    already existing bulleted list in powerpoint slide.

    please help!

  • This code snippet shows some two lines of bullet points with the values 'Hi' and 'INEED TO FIND THIS'. It should give you a idea how the bullet points are added. In your case I guess the .Text will be blank if you jusut wanted an empty bullet point

    paragraphProperties51.Append(bulletFont10);

    paragraphProperties51.Append(characterBullet10);

    A.Run run63 = new A.Run();

    A.RunProperties runProperties87 = new A.RunProperties(){ Language = "en-NZ", Dirty = false, SmartTagClean = false };

    A.Text text87 = new A.Text();

    text87.Text = "Hi";

    run63.Append(runProperties87);

    run63.Append(text87);

    paragraph102.Append(paragraphProperties51);

    paragraph102.Append(run63);

    A.Paragraph paragraph103 = new A.Paragraph();

    A.ParagraphProperties paragraphProperties52 = new A.ParagraphProperties(){ LeftMargin = 285750, Indent = -285750 };

    A.BulletFont bulletFont11 = new A.BulletFont(){ Typeface = "Arial", PitchFamily = 34, CharacterSet = 0 };

    A.CharacterBullet characterBullet11 = new A.CharacterBullet(){ Char = "•" };

    paragraphProperties52.Append(bulletFont11);

    paragraphProperties52.Append(characterBullet11);

    A.Run run64 = new A.Run();

    A.RunProperties runProperties88 = new A.RunProperties(){ Language = "en-NZ", Dirty = false, SmartTagClean = false };

    A.Text text88 = new A.Text();

    text88.Text = "INEED TO FIND THIS";

    run64.Append(runProperties88);

    run64.Append(text88);

  • Hi Andrewla,

    In the example you have mention above you have created new charecterbullets and bulletsfont. Which it quite easy.

    What if we need to use existing bullets in slides and add a new point with this existing bullet.

    Can u help me on this.

    Thanks,

    Pranay

  • Hi Mandar,

    Some how I manage to do the same as you required.

    Below is the code for the same.

    ---------------------------------------------------------

    static void Main(string[] args)

           {

         string pptfilepath = @"D:\openxml\POCs\testppts\testSample\text.pptx";

       using (PresentationDocument pDoc = PresentationDocument.Open(pptfilepath1, true))

               {

                   PresentationPart pPart = pDoc.PresentationPart;

                   SlidePart sdl = pPart.GetSlidePartsInOrder().First();

                     AddBullets(sdl, "add with existing bulleted points");

               }

           }

    public static void AddBullets(SlidePart slidePart1, string textToAppend)

           {

               Slide slide1 = slidePart1.Slide;

               CommonSlideData commonSlideData1 = slide1.GetFirstChild<CommonSlideData>();

               ShapeTree shapeTree1 = commonSlideData1.GetFirstChild<ShapeTree>();

               Shape shape1 = shapeTree1.GetFirstChild<Shape>();

               TextBody textBody1 = shape1.GetFirstChild<TextBody>();

               A.Paragraph paragraph1 = textBody1.GetFirstChild<A.Paragraph>();

               A.CharacterBullet Charbullets = (A.CharacterBullet)paragraph1.ParagraphProperties.OfType<A.CharacterBullet>().First().Clone();

               A.BulletFont bulletsfonts = (A.BulletFont)paragraph1.ParagraphProperties.OfType<A.BulletFont>().First().Clone();

               A.Paragraph paragraph2 = new A.Paragraph();

               A.ParagraphProperties paragraphProperties1 = new A.ParagraphProperties();

               paragraphProperties1.Append(bulletsfonts);

               paragraphProperties1.Append(Charbullets);

               A.Run run = new A.Run();

               A.RunProperties runProperties = new A.RunProperties() { Language = "en-US", SmartTagClean = false };

               A.Text text = new A.Text();

               text.Text = textToAppend;

               run.Append(runProperties);

               run.Append(text);

               A.EndParagraphRunProperties endParagraphRunProperties1 = new A.EndParagraphRunProperties() { Language = "en-US", Dirty = false };

               paragraph2.Append(paragraphProperties1);

               paragraph2.Append(run);

               paragraph2.Append(endParagraphRunProperties1);

               textBody1.Append(paragraph2);

               slide1.Save();

           }

    -------------------------------------------------------

    Note: your ppt slide shoul have at leat one bullted text in text box.

     

    Enjoy,

    Pranay

  • ModifyList.rar

    Hi,     
         To add an item to the existing list, you have to add a Paragraph object to the existing TextBody.
          I have attached a sample solution. Please have a look.

  • Hi Pramod,

    Yes you r right.

    Even, I did the same in the above example.

Page 1 of 1 (6 items)