# Convert HTML to Image in C++

> Convert HTML to image in C++. Use the C++ library API to convert HTML files to images.

Source: https://products.aspose.com/slides/cpp/conversion/html-to-image/
Updated: 2026-07-30



## Convert HTML to Image in C++

[**Aspose.Slides for C++**](/slides/cpp/) is a presentation processing API that can import HTML content and render slides as image files.

Aspose.Slides for C++ can convert HTML content to image formats and other presentation-related formats.

## Convert HTML to Image Using C++

To convert HTML to an image, create a new Presentation, remove its default slide, import the HTML content with `AddFromHtml`, and save each resulting slide as an image.

### C++ code for converting HTML into Image

```cpp
auto presentation = MakeObject<Presentation>();
presentation->get_Slides()->RemoveAt(0);

auto htmlStream = File::OpenRead(u"page.html");
presentation->get_Slides()->AddFromHtml(htmlStream);
htmlStream->Dispose();

auto slideCount = presentation->get_Slides()->get_Count();
for (int index = 0; index < slideCount; index++)
{
    auto slide = presentation->get_Slide(index);
    auto fileName = String::Format(u"slide_{0}.png", index);
    auto image = slide->GetImage();
    image->Save(fileName);
    image->Dispose();
}

presentation->Dispose();
```

## How to Convert HTML to Image Using Aspose.Slides for C++ API

These are the steps to convert HTML to Image in C++.

Install [**Aspose.Slides for C++**](/slides/cpp/).

Add a library reference (import the library) to your C++ project.

Open the source HTML file in C++.

Save the result as an image file.

## Convert HTML to Other Supported Formats

- [HTML TO JPG](/slides/cpp/conversion/html-to-jpg/)
- [HTML TO TIFF](/slides/cpp/conversion/html-to-tiff/)
- [HTML TO XML](/slides/cpp/conversion/html-to-xml/)
