Merge HTML Files and Export to Images in Python
Combine HTML documents and render the resulting slides as PNG images with a cross-platform Python API
Merge HTML Files and Export to Images Using Aspose.Slides
Aspose.Slides for Python via .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
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 .
Import the
aspose.slidesmodule in your Python project.Create a
Presentationand remove its default blank slide.Open each HTML file and pass its stream to
SlideCollection.add_from_html.Render each imported
SlidewithSlide.get_image, then callIImage.savewithImageFormat.PNG.
Merge Other Files
You can also combine files in other formats.