### Install libgdiplus and libc6-dev Source: https://docs.aspose.com/slides/net/how-to-run-aspose-slides-in-docker Command to install necessary packages for System.Drawing.Common. ```bash RUN apt-get install -y libgdiplus && apt-get install -y libc6-dev ``` -------------------------------- ### Divide Method Example Source: https://docs.aspose.com/slides/net/powerpoint-math-equations This example demonstrates how to create a fraction using the Divide method with a specified fraction type. ```csharp IMathElement numerator = new MathematicalText("x"); IMathFraction fraction = numerator.Divide("y", MathFractionTypes.Linear); ``` -------------------------------- ### Default Command on Start Source: https://docs.aspose.com/slides/net/how-to-run-aspose-slides-in-docker Defines the default command to run when the container starts. ```bash CMD ./build/netcore.linux.tests.sh ``` -------------------------------- ### Example output of running the container Source: https://docs.aspose.com/slides/net/how-to-run-aspose-slides-in-docker This is an example of the output seen after running the Docker container, showing the results of the Aspose.Slides tests. ```text NAnt 0.92 (Build 0.92.4543.0; release; 6/9/2012) Copyright (C) 2001-2012 Gerry Shaw http://nant.sourceforge.net netcore20_runtests: [delete] Deleting directory 'c:\slides-src\build-out\netcore20\test-results\'. [mkdir] Creating directory 'c:\slides-src\build-out\netcore20\test-results\'. ... [exec] Results File: C:\slides-src\/build-out/netcore20/test-results//main\Aspose.Slides.FuncTests.NetCore.trx [exec] Total tests: 2338. Passed: 2115. Failed: 19. Skipped: 204. ... [exec] Results File: C:\slides-src\/build-out/netcore20/test-results//main\Aspose.Slides.RegrTests.NetCore.trx [exec] Total tests: 2728. Passed: 2147. Failed: 110. Skipped: 471. ``` -------------------------------- ### Join Method Example Source: https://docs.aspose.com/slides/net/powerpoint-math-equations This example shows how to join two mathematical elements into a mathematical block using the Join method. ```csharp IMathElement element1 = new MathematicalText("x"); IMathElement element2 = new MathematicalText("y"); IMathBlock block = element1.Join(element2); ``` -------------------------------- ### MathLimit and MathFunction Example Source: https://docs.aspose.com/slides/net/powerpoint-math-equations This example demonstrates how to create a limit expression using MathLimit and MathFunction classes. ```csharp var funcName = new MathLimit(new MathematicalText("lim"), new MathematicalText("𝑥→∞")); var mathFunc = new MathFunction(funcName, new MathematicalText("𝑥")); ``` -------------------------------- ### Install Aspose.Slides.NET via Package Manager Console Source: https://docs.aspose.com/slides/net/installation This command installs the Aspose.Slides.NET package. Adding the -prerelease suffix installs the latest release including hotfixes. ```powershell Install-Package Aspose.Slides.NET ``` -------------------------------- ### SetUpperLimit and SetLowerLimit Methods Example Source: https://docs.aspose.com/slides/net/powerpoint-math-equations Shows how to set upper and lower limits for mathematical expressions, often used with limit functions. ```csharp var mathExpression = MathText.Create("lim").SetLowerLimit("x→∞").Function("x"); ``` -------------------------------- ### Getting slide image with the new API (version 24.8 and later) Source: https://docs.aspose.com/slides/net/net6 This code example shows how to get a slide image using the modern API in Aspose.Slides for .NET, starting from version 24.8. ```csharp static Aspose.Slides.IImage GetThumbnail(Presentation presentation) { return presentation.Slides[0].GetImage(); } ``` -------------------------------- ### Getting a Presentation Thumbnail (Modern API) Source: https://docs.aspose.com/slides/net/modern-api Example of getting presentation thumbnails using the modern Aspose.Slides API. ```csharp using (Presentation pres = new Presentation("pres.pptx")) { var images = pres.GetImages(new RenderingOptions(), new Size(1980, 1028)); try { for (var index = 0; index < images.Length; index++) { IImage thumbnail = images[index]; thumbnail.Save($"slide{index}.png", ImageFormat.Png); } } finally { foreach (IImage image in images) { image.Dispose(); } } } ``` -------------------------------- ### Legacy Aspose.Slides for .NET Approach Source: https://docs.aspose.com/slides/net/how-to-create-hello-world-presentation-document This code snippet demonstrates how to create a 'Hello World' presentation using the legacy Aspose.Slides for .NET API. It includes steps for instantiating a Presentation object, setting a license, adding a slide, adding a rectangle with text, and saving the presentation. ```csharp Copy//Instantiate a Presentation object that represents a PPT file Presentation pres = new Presentation(); //Create a License object License license = new License(); //Set the license of Aspose.Slides for .NET to avoid the evaluation limitations license.SetLicense("Aspose.Slides.lic"); //Adding an empty slide to the presentation and getting the reference of //that empty slide Slide slide = pres.AddEmptySlide(); //Adding a rectangle (X=2400, Y=1800, Width=1000 & Height=500) to the slide Aspose.Slides.Rectangle rect = slide.Shapes.AddRectangle(2400, 1800, 1000, 500); //Hiding the lines of rectangle rect.LineFormat.ShowLines = false; //Adding a text frame to the rectangle with "Hello World" as a default text rect.AddTextFrame("Hello World"); //Removing the first slide of the presentation which is always added by //Aspose.Slides for .NET by default while creating the presentation pres.Slides.RemoveAt(0); //Writing the presentation as a PPT file pres.Write("C:\\hello.ppt"); ``` -------------------------------- ### Getting a Presentation Thumbnail (Deprecated API) Source: https://docs.aspose.com/slides/net/modern-api Example of getting presentation thumbnails using the deprecated System.Drawing API. ```csharp using (Presentation pres = new Presentation("pres.pptx")) { var bitmaps = pres.GetThumbnails(new RenderingOptions(), new Size(1980, 1028)); try { for (var index = 0; index < bitmaps.Length; index++) { Bitmap thumbnail = bitmaps[index]; thumbnail.Save($"slide{index}.png", ImageFormat.Png); } } finally { foreach (Bitmap bitmap in bitmaps) { bitmap.Dispose(); } } } ``` -------------------------------- ### Getting a Shape Thumbnail (Modern API) Source: https://docs.aspose.com/slides/net/modern-api Example of getting a shape thumbnail using the modern Aspose.Slides API. ```csharp using (Presentation pres = new Presentation("pres.pptx")) { pres.Slides[0].Shapes[0].GetImage().Save("shape.png"); } ``` -------------------------------- ### Base Image Explanation Source: https://docs.aspose.com/slides/net/how-to-run-aspose-slides-in-docker Explanation of the base image used in the Dockerfile. ```text FROM microsoft/dotnet:2.1-sdk-bionic AS build: ``` -------------------------------- ### Nary and Integral Methods Example Source: https://docs.aspose.com/slides/net/powerpoint-math-equations Illustrates the creation of N-ary operators and integrals using the Nary() and Integral() methods. ```csharp IMathBlock baseArg = new MathematicalText("x").Join(new MathematicalText("dx").ToBox()); IMathNaryOperator integral = baseArg.Integral(MathIntegralTypes.Simple, "0", "1"); ``` -------------------------------- ### Getting a Shape Thumbnail (Deprecated API) Source: https://docs.aspose.com/slides/net/modern-api Example of getting a shape thumbnail using the deprecated System.Drawing API. ```csharp using (Presentation pres = new Presentation("pres.pptx")) { pres.Slides[0].Shapes[0].GetThumbnail().Save("shape.png"); } ``` -------------------------------- ### Add a Table Source: https://docs.aspose.com/slides/net/examples/elements/table Create a simple table with two rows and two columns. ```csharp static void AddTable() { using var presentation = new Presentation(); var slide = presentation.Slides[0]; double[] widths = { 80, 80 }; double[] heights = { 30, 30 }; var table = slide.Shapes.AddTable(50, 50, widths, heights); } ``` -------------------------------- ### Getting a Slide Thumbnail (Modern API) Source: https://docs.aspose.com/slides/net/modern-api Example of getting a slide thumbnail using the modern Aspose.Slides API. ```csharp using (Presentation pres = new Presentation("pres.pptx")) { pres.Slides[0].GetImage().Save("slide1.png"); } ``` -------------------------------- ### Getting a Slide Thumbnail (Deprecated API) Source: https://docs.aspose.com/slides/net/modern-api Example of getting a slide thumbnail using the deprecated System.Drawing API. ```csharp using (Presentation pres = new Presentation("pres.pptx")) { pres.Slides[0].GetThumbnail().Save("slide1.png"); } ``` -------------------------------- ### Get Slide Titles Source: https://docs.aspose.com/slides/net/get-the-titles-of-all-the-slides This code example demonstrates how to retrieve and print the titles of all slides in a PowerPoint presentation using Aspose.Slides for .NET. ```csharp string FilePath = @"..\..\..\..\Sample Files\"; string FileName = FilePath + "Get all the text in a slide.pptx"; int numberOfSlides = CountSlides(FileName); System.Console.WriteLine("Number of slides = {0}", numberOfSlides); string slideText; for (int i = 0; i < numberOfSlides; i++) { GetSlideIdAndText(out slideText, FileName, i); System.Console.WriteLine("Slide #{0} contains: {1}", i + 1, slideText); } System.Console.ReadKey(); public static int CountSlides(string presentationFile) { // Open the presentation as read-only. using (PresentationDocument presentationDocument = PresentationDocument.Open(presentationFile, false)) { // Pass the presentation to the next CountSlides method // and return the slide count. return CountSlides(presentationDocument); } } // Count the slides in the presentation. public static int CountSlides(PresentationDocument presentationDocument) { // Check for a null document object. if (presentationDocument == null) { throw new ArgumentNullException("presentationDocument"); } int slidesCount = 0; // Get the presentation part of document. PresentationPart presentationPart = presentationDocument.PresentationPart; // Get the slide count from the SlideParts. if (presentationPart != null) { slidesCount = presentationPart.SlideParts.Count(); } // Return the slide count to the previous method. return slidesCount; } public static void GetSlideIdAndText(out string sldText, string docName, int index) { using (PresentationDocument ppt = PresentationDocument.Open(docName, false)) { // Get the relationship ID of the first slide. PresentationPart part = ppt.PresentationPart; OpenXmlElementList slideIds = part.Presentation.SlideIdList.ChildElements; string relId = (slideIds[index] as SlideId).RelationshipId; // Get the slide part from the relationship ID. SlidePart slide = (SlidePart)part.GetPartById(relId); // Build a StringBuilder object. StringBuilder paragraphText = new StringBuilder(); // Get the inner text of the slide: IEnumerable texts = slide.Slide.Descendants(); foreach (A.Text text in texts) { paragraphText.Append(text.Text); } sldText = paragraphText.ToString(); } } ``` -------------------------------- ### Aspose.Slides for .NET Example Source: https://docs.aspose.com/slides/net/create-a-new-presentation This code example shows how to create a new presentation, add a title slide, set its text, and save it using Aspose.Slides for .NET. ```csharp //Create a presentation Presentation pres = new Presentation(); //Add the title slide ISlide slide = pres.Slides.AddEmptySlide(pres.LayoutSlides[0]); //Set the title text ((IAutoShape)slide.Shapes[0]).TextFrame.Text = "Slide Title Heading"; //Set the sub title text ((IAutoShape)slide.Shapes[1]).TextFrame.Text = "Slide Title Sub-Heading"; //Write output to disk pres.Save("c:\\data\\outAsposeSlides.pptx", SaveFormat.Ppt); ``` -------------------------------- ### Radical Method Example Source: https://docs.aspose.com/slides/net/powerpoint-math-equations Demonstrates how to specify the mathematical root of a given degree using the Radical() method. ```csharp var radical = new MathematicalText("x").Radical("3"); ``` -------------------------------- ### Get the Entire Slide Background Source: https://docs.aspose.com/slides/net/get-the-entire-presentation-slide-background-as-an-image This code example extracts the entire presentation slide background as an image. ```csharp var slideIndex = 0; var imageScale = 1; using var presentation = new Presentation("sample.pptx"); var slideSize = presentation.SlideSize.Size; var slide = presentation.Slides[slideIndex]; using var tempPresentation = new Presentation(); tempPresentation.SlideSize.SetSize(slideSize.Width, slideSize.Height, SlideSizeScaleType.DoNotScale); var clonedSlide = tempPresentation.Slides.AddClone(slide); clonedSlide.Shapes.Clear(); using var background = clonedSlide.GetImage(imageScale, imageScale); background.Save("output.png", ImageFormat.Png); ``` -------------------------------- ### Get all the text in a slide Source: https://docs.aspose.com/slides/net/get-all-the-text-in-all-the-slides This code example demonstrates how to extract all text content from each slide in a PowerPoint presentation using Aspose.Slides for .NET. ```csharp string FilePath = @"..\..\..\..\Sample Files\"; string FileName = FilePath + "Get all the text in a slide.pptx"; int numberOfSlides = CountSlides(FileName); System.Console.WriteLine("Number of slides = {0}", numberOfSlides); string slideText; for (int i = 0; i < numberOfSlides; i++) { slideText = GetSlideText(FileName, i); System.Console.WriteLine("Slide #{0} contains: {1}", i + 1, slideText); } System.Console.ReadKey(); public static int CountSlides(string presentationFile) { //Instantiate PresentationEx class that represents PPTX using (Presentation pres = new Presentation(presentationFile)) { return pres.Slides.Count; } } public static string GetSlideText(string docName, int index) { string sldText = ""; //Instantiate PresentationEx class that represents PPTX using (Presentation pres = new Presentation(docName)) { //Access the slide ISlide sld = pres.Slides[index]; //Iterate through shapes to find the placeholder foreach (Shape shp in sld.Shapes) if (shp.Placeholder != null) { //get the text of each placeholder sldText += ((AutoShape)shp).TextFrame.Text; } } return sldText; } ``` -------------------------------- ### VSTO Example Source: https://docs.aspose.com/slides/net/create-a-chart-in-a-microsoft-powerpoint-presentation This code snippet demonstrates how to ensure that an instance of PowerPoint is running and optionally add a presentation and a slide. ```csharp public static void EnsurePowerPointIsRunning(bool blnAddPresentation) { EnsurePowerPointIsRunning(blnAddPresentation, false); } public static void EnsurePowerPointIsRunning() { EnsurePowerPointIsRunning(false, false); } public static void EnsurePowerPointIsRunning(bool blnAddPresentation, bool blnAddSlide) { string strName = null; // Try accessing the Name property. If it throws an exception, start a new instance of PowerPoint. try { strName = objPPT.Name; } catch (Exception ex) { StartPowerPoint(); } // blnAddPresentation is used to ensure that a presentation is loaded. if (blnAddPresentation == true) { try { strName = objPres.Name; } catch (Exception ex) { objPres = objPPT.Presentations.Add(MsoTriState.msoTrue); } } // blnAddSlide is used to ensure that there is at least one slide in the presentation. if (blnAddSlide) { try { strName = objPres.Slides[1].Name; } catch (Exception ex) { Microsoft.Office.Interop.PowerPoint.Slide objSlide = null; Microsoft.Office.Interop.PowerPoint.CustomLayout objCustomLayout = null; objCustomLayout = objPres.SlideMaster.CustomLayouts[1]; objSlide = objPres.Slides.AddSlide(1, objCustomLayout); objSlide.Layout = Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText; objCustomLayout = null; objSlide = null; } } } ``` -------------------------------- ### VSTO Example Source: https://docs.aspose.com/slides/net/create-a-new-presentation This code example shows how to create a new presentation, add a title slide, set its text, and save it using VSTO. ```csharp //Note: PowerPoint is a namespace which has been defined above like this //using PowerPoint = Microsoft.Office.Interop.PowerPoint; //Create a presentation PowerPoint.Presentation pres = Globals.ThisAddIn.Application .Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse); //Get the title slide layout PowerPoint.CustomLayout layout = pres.SlideMaster. CustomLayouts[PowerPoint.PpSlideLayout.ppLayoutTitle]; //Add a title slide. PowerPoint.Slide slide = pres.Slides.AddSlide(1, layout); //Set the title text slide.Shapes.Title.TextFrame.TextRange.Text = "Slide Title Heading"; //Set the sub title text slide.Shapes[2].TextFrame.TextRange.Text = "Slide Title Sub-Heading"; //Write the output to disk pres.SaveAs("c:\\outVSTO.ppt", PowerPoint.PpSaveAsFileType.ppSaveAsPresentation, Microsoft.Office.Core.MsoTriState.msoFalse); ``` -------------------------------- ### Full example using extern alias Source: https://docs.aspose.com/slides/net/net6 A complete example showing the usage of extern alias for Aspose.Slides to get a slide thumbnail. ```csharp extern alias Slides; using Slides::Aspose.Slides; static Slides::System.Drawing.Image GetThumbnail(Presentation pres) { return pres.Slides[0].GetThumbnail(); } ``` -------------------------------- ### New Aspose.Slides for .NET 13.x Approach Source: https://docs.aspose.com/slides/net/how-to-create-hello-world-presentation-document This code snippet shows how to create a 'Hello World' presentation using the newer Aspose.Slides for .NET API (version 13.x and above). It involves getting the first slide, adding an AutoShape (Rectangle), adding a text frame, customizing text and shape colors, and saving the presentation in PPTX format. ```csharp Copy// Instantiate Presentation Presentation pres = new Presentation(); // Get the first slide ISlide sld = (ISlide)pres.Slides[0]; // Add an AutoShape of Rectangle type IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50); // Add ITextFrame to the Rectangle ashp.AddTextFrame("Hello World"); // Change the text color to Black (which is White by default) ashp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.FillType = FillType.Solid; ashp.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FillFormat.SolidFillColor.Color = Color.Black; // Change the line color of the rectangle to White ashp.ShapeStyle.LineColor.Color = Color.White; // Remove any fill formatting in the shape ashp.FillFormat.FillType = FillType.NoFill; // Save the presentation to disk pres.Save("D:\\data\\HelloWorld.pptx", SaveFormat.Pptx); ``` -------------------------------- ### Get all the text in all the slides Source: https://docs.aspose.com/slides/net/get-all-the-text-in-all-the-slides This code example demonstrates how to iterate through all slides in a presentation, count them, and extract all text content from each slide using the OpenXML SDK. ```C# string FilePath = @"..\..\..\..\Sample Files\"; string FileName = FilePath + "Get all the text in a slide.pptx"; int numberOfSlides = CountSlides(FileName); System.Console.WriteLine("Number of slides = {0}", numberOfSlides); string slideText; for (int i = 0; i < numberOfSlides; i++) { GetSlideIdAndText(out slideText, FileName, i); System.Console.WriteLine("Slide #{0} contains: {1}", i + 1, slideText); } System.Console.ReadKey(); public static int CountSlides(string presentationFile) { // Open the presentation as read-only. using (PresentationDocument presentationDocument = PresentationDocument.Open(presentationFile, false)) { // Pass the presentation to the next CountSlides method // and return the slide count. return CountSlides(presentationDocument); } } // Count the slides in the presentation. public static int CountSlides(PresentationDocument presentationDocument) { // Check for a null document object. if (presentationDocument == null) { throw new ArgumentNullException("presentationDocument"); } int slidesCount = 0; // Get the presentation part of document. PresentationPart presentationPart = presentationDocument.PresentationPart; // Get the slide count from the SlideParts. if (presentationPart != null) { slidesCount = presentationPart.SlideParts.Count(); } // Return the slide count to the previous method. return slidesCount; } public static void GetSlideIdAndText(out string sldText, string docName, int index) { using (PresentationDocument ppt = PresentationDocument.Open(docName, false)) { // Get the relationship ID of the first slide. PresentationPart part = ppt.PresentationPart; OpenXmlElementList slideIds = part.Presentation.SlideIdList.ChildElements; string relId = (slideIds[index] as SlideId).RelationshipId; // Get the slide part from the relationship ID. SlidePart slide = (SlidePart)part.GetPartById(relId); // Build a StringBuilder object. StringBuilder paragraphText = new StringBuilder(); // Get the inner text of the slide: IEnumerable texts = slide.Slide.Descendants(); foreach (A.Text text in texts) { paragraphText.Append(text.Text); } sldText = paragraphText.ToString(); } } ``` -------------------------------- ### Get Effective Text Frame and Portion Properties Source: https://docs.aspose.com/slides/net/shape-effective-properties This example demonstrates how to obtain the effective text frame and portion formatting properties of a shape in a presentation. ```csharp using (Presentation pres = new Presentation("Presentation1.pptx")) { IAutoShape shape = pres.Slides[0].Shapes[0] as IAutoShape; ITextFrameFormat localTextFrameFormat = shape.TextFrame.TextFrameFormat; ITextFrameFormatEffectiveData effectiveTextFrameFormat = localTextFrameFormat.GetEffective(); IPortionFormat localPortionFormat = shape.TextFrame.Paragraphs[0].Portions[0].PortionFormat; IPortionFormatEffectiveData effectivePortionFormat = localPortionFormat.GetEffective(); } ``` -------------------------------- ### SetSubscript, SetSuperscript, SetSubSuperscriptOnTheRight, SetSubSuperscriptOnTheLeft Methods Example Source: https://docs.aspose.com/slides/net/powerpoint-math-equations Provides an example of setting subscripts and superscripts, including simultaneous setting on either side. ```csharp var script = new MathematicalText("y").SetSubSuperscriptOnTheLeft("2x", "3z"); ``` -------------------------------- ### Get all animation effects, including those inherited from placeholders Source: https://docs.aspose.com/slides/net/shape-animation This example shows how to get animation effects applied to a shape, including those inherited from placeholders on layout and master slides, using the GetBasePlaceholder method. ```csharp using (Presentation presentation = new Presentation("sample.pptx")) { ISlide slide = presentation.Slides[0]; // Get animation effects of the shape on the normal slide. IShape shape = slide.Shapes[0]; IEffect[] shapeEffects = slide.Timeline.MainSequence.GetEffectsByShape(shape); // Get animation effects of the placeholder on the layout slide. IShape layoutShape = shape.GetBasePlaceholder(); IEffect[] layoutShapeEffects = slide.LayoutSlide.Timeline.MainSequence.GetEffectsByShape(layoutShape); // Get animation effects of the placeholder on the master slide. IShape masterShape = layoutShape.GetBasePlaceholder(); IEffect[] masterShapeEffects = slide.LayoutSlide.MasterSlide.Timeline.MainSequence.GetEffectsByShape(masterShape); Console.WriteLine("Main sequence of shape effects:"); PrintEffects(masterShapeEffects); PrintEffects(layoutShapeEffects); PrintEffects(shapeEffects); } ``` ```csharp static void PrintEffects(IEnumerable effects) { foreach (IEffect effect in effects) { Console.WriteLine($"{effect.Type} {effect.Subtype}"); } } ``` -------------------------------- ### Get Effective Properties of a Text Style Source: https://docs.aspose.com/slides/net/shape-effective-properties Provides a code example for obtaining effective text style properties, including paragraph formatting details like depth, indent, and alignment for different style levels, using Aspose.Slides for .NET. ```csharp using (Presentation pres = new Presentation("Presentation1.pptx")) { IAutoShape shape = pres.Slides[0].Shapes[0] as IAutoShape; ITextStyleEffectiveData effectiveTextStyle = shape.TextFrame.TextFrameFormat.TextStyle.GetEffective(); for (int i = 0; i <= 8; i++) { IParagraphFormatEffectiveData effectiveStyleLevel = effectiveTextStyle.GetLevel(i); Console.WriteLine("= Effective paragraph formatting for style level #" + i + " ="); Console.WriteLine("Depth: " + effectiveStyleLevel.Depth); Console.WriteLine("Indent: " + effectiveStyleLevel.Indent); Console.WriteLine("Alignment: " + effectiveStyleLevel.Alignment); Console.WriteLine("Font alignment: " + effectiveStyleLevel.FontAlignment); } } ``` -------------------------------- ### Open a Presentation and Get Slide Count Source: https://docs.aspose.com/slides/net/open-presentation This example demonstrates how to open an existing presentation file and retrieve the total number of slides it contains. ```csharp using (Presentation presentation = new Presentation("Sample.pptx")) { // Print the total number of slides in the presentation. System.Console.WriteLine(presentation.Slides.Count); } ``` -------------------------------- ### Get or Set the Organization Chart Layout Source: https://docs.aspose.com/slides/net/manage-smartart This example demonstrates how to create an organization chart and set the layout for the root node to LeftHanging. ```csharp using (Presentation presentation = new Presentation()) { ISmartArt smartArt = presentation.Slides[0].Shapes.AddSmartArt( 10, 10, 400, 300, SmartArtLayoutType.OrganizationChart); ISmartArtNode rootNode = smartArt.Nodes[0]; rootNode.OrganizationChartLayout = OrganizationChartLayoutType.LeftHanging; presentation.Save("OrganizationChartLayout_out.pptx", SaveFormat.Pptx); } ``` -------------------------------- ### Full source code example Source: https://docs.aspose.com/slides/net/web-extensions Complete source code for creating an HTML presentation with animated page transitions from a PDF document. ```csharp using (Presentation pres = new Presentation()) { pres.Slides.RemoveAt(0); pres.Slides.AddFromPdf("sample.pdf"); pres.Slides[0].SlideShowTransition.Type = TransitionType.Fade; pres.Slides[1].SlideShowTransition.Type = TransitionType.RandomBar; pres.Slides[2].SlideShowTransition.Type = TransitionType.Cover; pres.Slides[3].SlideShowTransition.Type = TransitionType.Dissolve; pres.Slides[4].SlideShowTransition.Type = TransitionType.Switch; pres.Slides[5].SlideShowTransition.Type = TransitionType.Pan; pres.Slides[6].SlideShowTransition.Type = TransitionType.Ferris; pres.Slides[7].SlideShowTransition.Type = TransitionType.Pull; pres.Slides[8].SlideShowTransition.Type = TransitionType.Plus; WebDocumentOptions options = new WebDocumentOptions { TemplateEngine = new RazorTemplateEngine(), OutputSaver = new FileOutputSaver(), AnimateTransitions = true }; WebDocument document = pres.ToSinglePageWebDocument(options, "templates\\single-page", "animated-pdf"); document.Save(); } ``` -------------------------------- ### Update Packages Command Source: https://docs.aspose.com/slides/net/how-to-run-aspose-slides-in-docker Command to update the package database and install apt-utils. ```bash RUN apt-get update -y && apt-get install -y apt-utils ``` -------------------------------- ### Get a Chart Image Source: https://docs.aspose.com/slides/net/export-chart This code example demonstrates how to extract an image of a specific chart from a presentation and save it as a PNG file. ```csharp using (Presentation presentation = new Presentation("test.pptx")) { ISlide slide = presentation.Slides[0]; IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 600, 400); using (IImage image = chart.GetImage()) { image.Save("image.png", ImageFormat.Png); } } ``` -------------------------------- ### Dockerfile for Windows Server Core with .NET SDK Source: https://docs.aspose.com/slides/net/how-to-run-aspose-slides-in-docker This Dockerfile installs the .NET Core SDK on a Windows Server Core base image and configures the environment for building and testing Aspose.Slides. ```dockerfile # escape= FROM microsoft/windowsservercore:1803 AS installer-env #set powershell default executor SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] # escape= FROM microsoft/windowsservercore:1803 AS installer-env #set powershell default executor SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] # Retrieve .NET Core SDK ENV DOTNET_SDK_VERSION 2.1.301 ENV DOTNET_PATH "c:/Program Files/dotnet" RUN Invoke-WebRequest -OutFile dotnet.zip https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$Env:DOTNET_SDK_VERSION/dotnet-sdk-$Env:DOTNET_SDK_VERSION-win-x64.zip; $dotnet_sha512 = 'f2f6cc020f89dc4d4f8064cc914cffabde0ce422715138778a6bcbbb6803ca66d6fd967097a0209c47c89b85dd9e93db48486ac86999bd3a533e45b789fcea89'; if ((Get-FileHash dotnet.zip -Algorithm sha512).Hash -ne $dotnet_sha512) { Write-Host 'CHECKSUM VERIFICATION FAILED!'; exit 1; }; Expand-Archive dotnet.zip -DestinationPath $Env:DOTNET_PATH; #return cmd as default executor SHELL ["cmd", "/S", "/C"] # In order to set system PATH, ContainerAdministrator must be used USER ContainerAdministrator RUN setx /M PATH "%PATH%;c:/Program Files/dotnet" USER ContainerUser # create mount points VOLUME c:/slides-src #build and test Aspose.Slides on start WORKDIR c:/slides-src CMD .\external\buildtools\nant\nant.exe -buildfile:.\build\netcore.tests.build -D:obfuscate_eaz_use_mock=true -D:slidesnet.run.func.tests=true -D:slidesnet.run.regr.tests=true ``` -------------------------------- ### Save a Paragraph as an Image (Example 1) Source: https://docs.aspose.com/slides/net/manage-paragraph This example shows how to extract a specific paragraph from a shape in a presentation and save it as a PNG image with its original dimensions. It involves getting the shape's image, calculating the paragraph's bounds, and redrawing it onto a new bitmap. ```csharp using var presentation = new Presentation("sample.pptx"); var firstShape = presentation.Slides[0].Shapes[0] as IAutoShape; // Save the shape in memory as a bitmap. using var shapeImage = firstShape.GetImage(); using var shapeImageStream = new MemoryStream(); shapeImage.Save(shapeImageStream, ImageFormat.Png); // Create a shape bitmap from memory. shapeImageStream.Seek(0, SeekOrigin.Begin); using var shapeBitmap = Image.FromStream(shapeImageStream); // Calculate the boundaries of the second paragraph. var secondParagraph = firstShape.TextFrame.Paragraphs[1]; var paragraphRectangle = secondParagraph.GetRect(); // Calculate the size for the output image (minimum size - 1x1 pixel). var imageWidth = Math.Max(1, (int)Math.Ceiling(paragraphRectangle.Width)); var imageHeight = Math.Max(1, (int)Math.Ceiling(paragraphRectangle.Height)); // Prepare a bitmap for the paragraph. using var paragraphBitmap = new Bitmap(imageWidth, imageHeight); // Redraw the paragraph from the shape bitmap to the paragraph bitmap. using var imageGraphics = Graphics.FromImage(paragraphBitmap); var drawingRectangle = new RectangleF(0, 0, paragraphRectangle.Width, paragraphRectangle.Height); imageGraphics.DrawImage(shapeBitmap, drawingRectangle, paragraphRectangle, GraphicsUnit.Pixel); paragraphBitmap.Save("paragraph.png", System.Drawing.Imaging.ImageFormat.Png); ``` -------------------------------- ### Get Slide Background Value Source: https://docs.aspose.com/slides/net/presentation-background This C# example demonstrates how to obtain the effective background of a slide, considering master, layout, and theme, and then checks its fill type and color. ```csharp Copy// Create an instance of the Presentation class. using (Presentation presentation = new Presentation("Sample.pptx")) { ISlide slide = presentation.Slides[0]; // Retrieve the effective background, taking into account master, layout, and theme. IBackgroundEffectiveData effBackground = slide.Background.GetEffective(); if (effBackground.FillFormat.FillType == FillType.Solid) Console.WriteLine("Fill color: " + effBackground.FillFormat.SolidFillColor); else Console.WriteLine("Fill type: " + effBackground.FillFormat.FillType); } ``` -------------------------------- ### Get Custom Font Folders Example Source: https://docs.aspose.com/slides/net/custom-font Shows how to retrieve the list of font folders that Aspose.Slides checks for font files, including both custom and system font folders. ```csharp // This line outputs the folders that are checked for font files. // Those are folders added through the LoadExternalFonts method and system font folders. string[] fontFolders = FontsLoader.GetFontFolders(); ``` -------------------------------- ### Example Source: https://docs.aspose.com/slides/net/convert-presentation-to-html This code snippet demonstrates how to convert a presentation file to HTML format using Aspose.Slides for .NET. ```csharp //Instantiate a Presentation object that represents a presentation file Presentation pres = new Presentation("Conversion.ppt"); HtmlOptions htmlOpt = new HtmlOptions(); htmlOpt.HtmlFormatter = HtmlFormatter.CreateDocumentFormatter("", false); //Saving the presentation to HTML pres.Save("Converted.html", Aspose.Slides.Export.SaveFormat.Html, htmlOpt); ``` -------------------------------- ### Connection Site Count Source: https://docs.aspose.com/slides/net/public-api-and-backwards-incompatible-changes-in-aspose-slides-for-net-15-4-0 Shows how to get the number of connection sites available on a shape and potentially set a connector's start site index. ```csharp using(Presentation input = new Presentation()) { IShapeCollection shapes = input.Slides[0].Shapes; IConnector connector = shapes.AddConnector(ShapeType.BentConnector2, 0, 0, 10, 10); IAutoShape ellipse = shapes.AddAutoShape(ShapeType.Ellipse, 0, 100, 100, 100); IAutoShape rectangle = shapes.AddAutoShape(ShapeType.Rectangle, 100, 200, 100, 100); connector.StartShapeConnectedTo = ellipse; connector.EndShapeConnectedTo = rectangle; uint wantedIndex = 6; if (ellipse.ConnectionSiteCount > wantedIndex) { connector.StartShapeConnectionSiteIndex = wantedIndex; } input.Save("output.pptx", SaveFormat.Pptx); } ```