Add a Node to SmartArt in PowerPoint in C#

With the help of Spire.Presentation, we can easily add SmartArt shape to the presentation slides. We can add a new node to the existing SmartArt shape to presentation slides and the following code example demonstrates the same.

Step 1: Create a new PowerPoint document and load the sample document from file.

Presentation presentation = new Presentation();
presentation.LoadFromFile("Sample.pptx");

Step 2: Get the SmartArt from the presentation slide.

ISmartArt sa = presentation.Slides[0].Shapes[1] as ISmartArt;

Step 3: Add a node.

ISmartArtNode node = sa.Nodes.AddNode();

Step 4: Add text and set the text style for the node.

node.TextFrame.Text = "NewStep";
node.TextFrame.TextRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
node.TextFrame.TextRange.Fill.SolidColor.KnownColor = KnownColors.HotPink;

Step 5: Save the document to file.

presentation.SaveToFile("AddNode.pptx", FileFormat.Pptx2010);

Effective screenshot after adding a new node:

Add a Node to SmartArt in PowerPoint in C#

Full codes of adding a node to SmartArt:

Presentation presentation = new Presentation();
presentation.LoadFromFile("Sample.pptx");

ISmartArt sa = presentation.Slides[0].Shapes[1] as ISmartArt;

ISmartArtNode node = sa.Nodes.AddNode();

node.TextFrame.Text = "NewStep";
node.TextFrame.TextRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
node.TextFrame.TextRange.Fill.SolidColor.KnownColor = KnownColors.HotPink;

presentation.SaveToFile("AddNode.pptx", FileFormat.Pptx2010);