# Merge HTML Files and Export to Images in Python

> Merge multiple HTML files in Python and render the combined content as PNG images.

Source: https://products.aspose.com/slides/python-net/merge/html-to-image/
Updated: 2026-07-27



## Merge HTML Files and Export to Images Using Aspose.Slides

[*Aspose.Slides for Python via .NET*](/slides/python-net/) lets you import multiple HTML documents into one `Presentation` and render the resulting slides as images. Use `SlideCollection.add_from_html` to import each HTML stream, then call `Slide.get_image` and save each resulting `IImage` with `ImageFormat.PNG`.

## Merge HTML Files to PNG Images in Python

Create a `Presentation`, import the source HTML files in order, and render each generated `Slide` as a separate PNG image.

### Python code for merging HTML files and exporting the slides as PNG images

```python
html_file_paths = ["first.html", "second.html"]

with slides.Presentation() as presentation:
    presentation.slides.remove_at(0)

    for file_path in html_file_paths:
        with open(file_path, "rb") as html_stream:
            presentation.slides.add_from_html(html_stream)

    for slide in presentation.slides:
        file_path = f"merged_slide_{slide.slide_number}.png"
        with slide.get_image(1, 1) as slide_image:
            slide_image.save(file_path, slides.ImageFormat.PNG)
```

## How to Merge HTML Files and Export Them as Images in Python

Follow these steps to combine HTML files and render the resulting slides as PNG images.

Install [*Aspose.Slides for Python via .NET*](/slides/python-net/).

Import the `aspose.slides` module in your Python project.

Create a `Presentation` and remove its default blank slide.

Open each HTML file and pass its stream to `SlideCollection.add_from_html`.

Render each imported `Slide` with `Slide.get_image`, then call `IImage.save` with `ImageFormat.PNG`.

## Merge Other Files
