Insert HTML with image into the Presentation slides in C#

We have already demonstrated how to use Spire.Presentation to insert HTML formatted text to PowerPoint slide. Now from Spire.Presentation 3.4.1, it supports to insert html (including text, image, audio and video) into presentation slides and each html tag will be added to the slide as a separate shape. The following code snippets demonstrate how to.

Step 1: Create an instance of Presentation class.

Presentation ppt = new Presentation();

Step 2: Get the shapes on the first slide.

ShapeList shapes = ppt.Slides[0].Shapes;

Step 3: Add contents to shape from HTML code, which includes text and image.

shapes.AddFromHtml("<html><div><p>First paragraph</p><p><img src='https://cdn.e-iceblue.com/Logo.jpg'/></p><p>Second paragraph </p></html>");

Step 4: Save the document to file.

ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010);

Effective screenshot:

Insert HTML with image into the Presentation slides in C#

Full codes of how to insert HTML into the Presentation slides:

using Spire.Presentation;
using Spire.Presentation.Collections;
namespace InsertHTML
{
    class Program
    {
        static void Main(string[] args)
        {

            Presentation ppt = new Presentation();

            ShapeList shapes = ppt.Slides[0].Shapes;

            shapes.AddFromHtml("

First paragraph

Second paragraph

"); ppt.SaveToFile("Result.pptx", FileFormat.Pptx2010); } } }