public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); //Creating a presentation instance using (Presentation pres = new Presentation(dataDir + "AssistantNode.pptx")) { //Traverse through every shape inside first slide foreach (IShape shape in pres.Slides[0].Shapes) { //Check if shape is of SmartArt type if (shape is ISmartArt) { //Typecast shape to SmartArtEx ISmartArt smart = (SmartArt)shape; //Traversing through all nodes of SmartArt shape foreach (ISmartArtNode node in smart.AllNodes) { String tc = node.TextFrame.Text; //Check if node is Assitant node if (node.IsAssistant) { //Setting Assitant node to false and making it normal node node.IsAssistant = false; } } } } //Save Presentation pres.Save(dataDir + "ChangeAssitantNode.pptx", Aspose.Slides.Export.SaveFormat.Pptx); } //Creating a presentation instance }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } // Creating a presentation instance Presentation pres = new Presentation(); // Access the presentation slide ISlide slide = pres.Slides[0]; // Add Smart Art IShape ISmartArt smart = slide.Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.StackedList); // Accessing the SmartArt node at index 0 ISmartArtNode node = smart.AllNodes[0]; // Adding new child node at position 2 in parent node SmartArtNode chNode = (SmartArtNode)((SmartArtNodeCollection)node.ChildNodes).AddNodeByPosition(2); // Add Text chNode.TextFrame.Text = "Sample Text Added"; // Save Presentation pres.Save(dataDir + "AddSmartArtNodeByPosition_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); }
public static void Run() { //ExStart:ChangSmartArtShapeStyle // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); using (Presentation presentation = new Presentation(dataDir + "AccessSmartArtShape.pptx")) { // Traverse through every shape inside first slide foreach (IShape shape in presentation.Slides[0].Shapes) { // Check if shape is of SmartArt type if (shape is ISmartArt) { // Typecast shape to SmartArtEx ISmartArt smart = (ISmartArt)shape; // Checking SmartArt style if (smart.QuickStyle == SmartArtQuickStyleType.SimpleFill) { // Changing SmartArt Style smart.QuickStyle = SmartArtQuickStyleType.Cartoon; } } } // Saving Presentation presentation.Save(dataDir + "ChangeSmartArtStyle_out.pptx", SaveFormat.Pptx); } //ExEnd:ChangSmartArtShapeStyle }
public static void Run() { // ExStart:RemoveNode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); // Load the desired the presentation using (Presentation pres = new Presentation(dataDir + "RemoveNode.pptx")) { // Traverse through every shape inside first slide foreach (IShape shape in pres.Slides[0].Shapes) { // Check if shape is of SmartArt type if (shape is ISmartArt) { // Typecast shape to SmartArtEx ISmartArt smart = (ISmartArt)shape; if (smart.AllNodes.Count > 0) { // Accessing SmartArt node at index 0 ISmartArtNode node = smart.AllNodes[0]; // Removing the selected node smart.AllNodes.RemoveNode(node); } } } // Save Presentation pres.Save(dataDir + "RemoveSmartArtNode_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); } // ExEnd:RemoveNode }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } // Instantiate the presentation using (Presentation pres = new Presentation()) { // Access the presentation slide ISlide slide = pres.Slides[0]; // Add Smart Art Shape ISmartArt smart = slide.Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.BasicBlockList); // Saving presentation pres.Save(dataDir + "SimpleSmartArt_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx); } }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } // Instantiate the presentation Presentation pres = new Presentation(); // Accessing the first slide ISlide slide = pres.Slides[0]; // Adding the SmartArt shape in first slide ISmartArt smart = slide.Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.StackedList); // Accessing the SmartArt node at index 0 ISmartArtNode node = smart.AllNodes[0]; // Accessing the child node at position 1 in parent node int position = 1; SmartArtNode chNode = (SmartArtNode)node.ChildNodes[position]; // Printing the SmartArt child node parameters string outString = string.Format("j = {0}, Text = {1}, Level = {2}, Position = {3}", position, chNode.TextFrame.Text, chNode.Level, chNode.Position); Console.WriteLine(outString); }
public static void Run() { //ExStart:CheckSmartArtHiddenProperty // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); using (Presentation presentation = new Presentation()) { // Add SmartArt BasicProcess ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.RadialCycle); // Add node on SmartArt ISmartArtNode node = smart.AllNodes.AddNode(); // Check isHidden property bool hidden = node.IsHidden; // Returns true if (hidden) { // Do some actions or notifications } // Saving Presentation presentation.Save(dataDir + "CheckSmartArtHiddenProperty_out.pptx", SaveFormat.Pptx); } //ExEnd:CheckSmartArtHiddenProperty }
public static void Run() { //ExStart:AccessSmartArtParticularLayout // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); using (Presentation presentation = new Presentation(dataDir + "AccessSmartArtShape.pptx")) { // Traverse through every shape inside first slide foreach (IShape shape in presentation.Slides[0].Shapes) { // Check if shape is of SmartArt type if (shape is ISmartArt) { // Typecast shape to SmartArtEx ISmartArt smart = (ISmartArt)shape; // Checking SmartArt Layout if (smart.Layout == SmartArtLayoutType.BasicBlockList) { Console.WriteLine("Do some thing here...."); } } } } //ExEnd:AccessSmartArtParticularLayout }
//ExStart:OrganizationChart public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Charts(); using (Presentation pres = new Presentation(dataDir + "test.pptx")) { ISmartArt smartArt = pres.Slides[0].Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.PictureOrganizationChart); pres.Save(dataDir + "OrganizationChart.pptx", SaveFormat.Pptx); } }
public void ModFiles(string filePath, string fontName, int fontSize) { Presentation ppt = new Presentation(); ppt.LoadFromFile(filePath); StringBuilder sb = new StringBuilder(); for (int i = 0; i < ppt.Slides.Count; i++) { for (int j = 0; j < ppt.Slides[i].Shapes.Count; j++) { IAutoShape shape = ppt.Slides[i].Shapes[j] as IAutoShape; if (ppt.Slides[i].Shapes[j] is ISmartArt) { ISmartArt smartArt = ppt.Slides[i].Shapes[j] as ISmartArt; for (int k = 0; k < smartArt.Nodes.Count; k++) { //get text 3, text 4, text 5 foreach (TextParagraph tp in smartArt.Nodes[k].TextFrame.Paragraphs) { //set font and size foreach (TextRange tr in tp.TextRanges) { tr.LatinFont = new TextFont(fontName); tr.FontHeight = fontSize; } } var nodeText = smartArt.Nodes[k].TextFrame.Text; sb.Append(nodeText); } } else { if (ppt.Slides[i].Shapes[j] is IAutoShape && (ppt.Slides[i].Shapes[j] as IAutoShape).TextFrame != null) { //get text 1, text 2, text 3 foreach (TextParagraph tp in shape.TextFrame.Paragraphs) { //set font and size foreach (TextRange tr in tp.TextRanges) { tr.LatinFont = new TextFont(fontName); tr.FontHeight = fontSize; } sb.Append(tp.Text + Environment.NewLine); } } } } } ppt.SaveToFile(filePath, FileFormat.Pptx2010); }
private void CreateSlide1(IPresentation presentation) { ISlide slide1 = presentation.Slides[0]; ISmartArt smartArt = slide1.Shapes[0] as ISmartArt; smartArt.Background.FillType = FillType.Solid; smartArt.Background.SolidFill.Color = ColorObject.Wheat; smartArt.Background.SolidFill.Transparency = 100; smartArt.Nodes[0].Shapes[0].Fill.FillType = FillType.Solid; smartArt.Nodes[0].Shapes[0].Fill.SolidFill.Color = ColorObject.CornflowerBlue; smartArt.Nodes[1].Shapes[0].Fill.FillType = FillType.Solid; smartArt.Nodes[1].Shapes[0].Fill.SolidFill.Color = ColorObject.CornflowerBlue; smartArt.Nodes[2].Shapes[0].Fill.FillType = FillType.Solid; smartArt.Nodes[2].Shapes[0].Fill.SolidFill.Color = ColorObject.CornflowerBlue; }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //load the document from disk presentation.LoadFromFile(@"..\..\..\..\..\..\Data\SmartArt.pptx"); //get the SmartArt and collect nodes ISmartArt sa = presentation.Slides[0].Shapes[0] as ISmartArt; ISmartArtNodeCollection nodes = sa.Nodes; //remove the node to specific position nodes.RemoveNodeByPosition(2); presentation.SaveToFile("RemoveNodes.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("RemoveNodes.pptx"); }
public static void Run() { // ExStart:ChangeSmartArtLayout // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); using (Presentation presentation = new Presentation()) { // Add SmartArt BasicProcess ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicBlockList); // Change LayoutType to BasicProcess smart.Layout = SmartArtLayoutType.BasicProcess; // Saving Presentation presentation.Save(dataDir + "ChangeSmartArtLayout_out.pptx", SaveFormat.Pptx); } // ExEnd:ChangeSmartArtLayout }
public static void Run() { // ExStart:OrganizeChartLayoutType // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); using (Presentation presentation = new Presentation()) { // Add SmartArt BasicProcess ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.OrganizationChart); // Get or Set the organization chart type smart.Nodes[0].OrganizationChartLayout = OrganizationChartLayoutType.LeftHanging; // Saving Presentation presentation.Save(dataDir + "OrganizeChartLayoutType_out.pptx", SaveFormat.Pptx); } // ExEnd:OrganizeChartLayoutType }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Shapes(); // Instantiate Presentation class that represents the PPTX file Presentation pres = new Presentation(); // Add SmartArt ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicCycle); // Obtain the reference of a node by using its Index ISmartArtNode node = smart.Nodes[1]; // Get thumbnail Bitmap bmp = node.Shapes[0].GetThumbnail(); // Save thumbnail bmp.Save(dataDir + "SmartArt_ChildNote_Thumbnail_out.jpeg", ImageFormat.Jpeg); }
private void CreateSlide1(IPresentation presentation) { ISlide slide1 = presentation.Slides.Add(SlideLayoutType.Blank); ISmartArt smartArt = slide1.Shapes.AddSmartArt(SmartArtType.BasicBlockList, 100, 100, 640, 427); ISmartArtNode node1 = smartArt.Nodes[0]; node1.TextBody.AddParagraph("One"); ISmartArtNode node2 = smartArt.Nodes[1]; node2.TextBody.AddParagraph("Two"); ISmartArtNode node3 = smartArt.Nodes[2]; node3.TextBody.AddParagraph("Three"); ISmartArtNode node4 = smartArt.Nodes[3]; node4.TextBody.AddParagraph("Four"); ISmartArtNode node5 = smartArt.Nodes[4]; node5.TextBody.AddParagraph("Five"); }
public static void Run() { //ExStart:ChangeSmartArtState // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); using (Presentation presentation = new Presentation()) { // Add SmartArt BasicProcess ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicProcess); // Get or Set the state of SmartArt Diagram smart.IsReversed = true; bool flag = smart.IsReversed; // Saving Presentation presentation.Save(dataDir + "ChangeSmartArtState_out.pptx", SaveFormat.Pptx); } //ExEnd:ChangeSmartArtState }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); // Load the desired the presentation using (Presentation pres = new Presentation(dataDir + "AccessSmartArtShape.pptx")) { // Traverse through every shape inside first slide foreach (IShape shape in pres.Slides[0].Shapes) { // Check if shape is of SmartArt type if (shape is ISmartArt) { // Typecast shape to SmartArtEx ISmartArt smart = (ISmartArt)shape; System.Console.WriteLine("Shape Name:" + smart.Name); } } } }
public static void Run() { //ExStart:ChangeTextOnSmartArtNode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); using (Presentation presentation = new Presentation()) { // Add SmartArt BasicProcess ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicCycle); // Obtain the reference of a node by using its Index ISmartArtNode node = smart.Nodes[1]; // select second root node // Setting the text of the TextFrame node.TextFrame.Text = "Second root node"; // Saving Presentation presentation.Save(dataDir + "ChangeText_On_SmartArt_Node_out.pptx", SaveFormat.Pptx); } //ExEnd:ChangeTextOnSmartArtNode }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //load the document from disk presentation.LoadFromFile(@"..\..\..\..\..\..\Data\SmartArt.pptx"); //get the SmartArt ISmartArt sa = presentation.Slides[0].Shapes[0] as ISmartArt; //add a node ISmartArtNode node = sa.Nodes.AddNode(); //add text and set the text style node.TextFrame.Text = "AddText"; node.TextFrame.TextRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; node.TextFrame.TextRange.Fill.SolidColor.KnownColor = KnownColors.HotPink; presentation.SaveToFile("AddNode.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("AddNode.pptx"); }
public static void Run() { //ExStart:BulletFillFormat // The path to the documents directory. string dataDir = RunExamples.GetDataDir_SmartArts(); using (Presentation presentation = new Presentation()) { ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 500, 400, SmartArtLayoutType.VerticalPictureList); ISmartArtNode node = smart.AllNodes[0]; if (node.BulletFillFormat != null) { Image img = (Image) new Bitmap(dataDir + "aspose-logo.jpg"); IPPImage image = presentation.Images.AddImage(img); node.BulletFillFormat.FillType = FillType.Picture; node.BulletFillFormat.PictureFillFormat.Picture.Image = image; node.BulletFillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch; } presentation.Save(dataDir + "out.pptx", SaveFormat.Pptx); } //ExEnd:BulletFillFormat }
private void CreateSlide3(IPresentation presentation) { ISlide slide2 = presentation.Slides[2]; ISmartArt smartArt = slide2.Shapes[1] as ISmartArt; smartArt.Background.FillType = FillType.Solid; smartArt.Background.SolidFill.Color = ColorObject.Wheat; smartArt.Background.SolidFill.Transparency = 100; smartArt.Nodes[0].ChildNodes[0].Shapes[0].Fill.FillType = FillType.Solid; smartArt.Nodes[0].ChildNodes[0].Shapes[0].Fill.SolidFill.Color = ColorObject.CornflowerBlue; smartArt.Nodes[0].ChildNodes[0].Shapes[0].LineFormat.Weight = 5; smartArt.Nodes[0].ChildNodes[1].Shapes[0].Fill.FillType = FillType.Solid; smartArt.Nodes[0].ChildNodes[1].Shapes[0].Fill.SolidFill.Color = ColorObject.CornflowerBlue; smartArt.Nodes[0].ChildNodes[1].Shapes[0].LineFormat.Weight = 5; smartArt.Nodes[1].ChildNodes[0].Shapes[0].Fill.FillType = FillType.Solid; smartArt.Nodes[1].ChildNodes[0].Shapes[0].Fill.SolidFill.Color = ColorObject.CornflowerBlue; smartArt.Nodes[1].ChildNodes[0].Shapes[0].LineFormat.Weight = 5; smartArt.Nodes[1].ChildNodes[1].Shapes[0].Fill.FillType = FillType.Solid; smartArt.Nodes[1].ChildNodes[1].Shapes[0].Fill.SolidFill.Color = ColorObject.CornflowerBlue; smartArt.Nodes[1].ChildNodes[1].Shapes[0].LineFormat.Weight = 5; smartArt.Nodes[1].ChildNodes[2].Shapes[0].Fill.FillType = FillType.Solid; smartArt.Nodes[1].ChildNodes[2].Shapes[0].Fill.SolidFill.Color = ColorObject.CornflowerBlue; smartArt.Nodes[1].ChildNodes[2].Shapes[0].LineFormat.Weight = 5; }
public static void Run() { //ExStart:CustomChildNodesInSmartArt string dataDir = RunExamples.GetDataDir_SmartArts(); // Load the desired the presentation Presentation pres = new Presentation(dataDir + "AccessChildNodes.pptx"); { ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(20, 20, 600, 500, SmartArtLayoutType.OrganizationChart); // Move SmartArt shape to new position ISmartArtNode node = smart.AllNodes[1]; ISmartArtShape shape = node.Shapes[1]; shape.X += (shape.Width * 2); shape.Y -= (shape.Height / 2); // Change SmartArt shape's widths node = smart.AllNodes[2]; shape = node.Shapes[1]; shape.Width += (shape.Width / 2); // Change SmartArt shape's height node = smart.AllNodes[3]; shape = node.Shapes[1]; shape.Height += (shape.Height / 2); // Change SmartArt shape's rotation node = smart.AllNodes[4]; shape = node.Shapes[1]; shape.Rotation = 90; pres.Save(dataDir + "SmartArt.pptx", SaveFormat.Pptx); } //ExEnd:CustomChildNodesInSmartArt }
public static void Run() { // ExStart:GetTextFromSmartArtNode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_Text(); using (Presentation presentation = new Presentation("Presentation.pptx")) { ISlide slide = presentation.Slides[0]; ISmartArt smartArt = (ISmartArt)slide.Shapes[0]; ISmartArtNodeCollection smartArtNodes = smartArt.AllNodes; foreach (ISmartArtNode smartArtNode in smartArtNodes) { foreach (ISmartArtShape nodeShape in smartArtNode.Shapes) { if (nodeShape.TextFrame != null) { Console.WriteLine(nodeShape.TextFrame.Text); } } } } }