# Convert HTML to PDF in Python

> Convert HTML content to PDF in Python. Use the Aspose.Slides Python API to import HTML and export the generated presentation as a PDF document.

Source: https://products.aspose.com/slides/python-net/conversion/html-to-pdf/
Updated: 2026-07-23



## Convert HTML to PDF in Python

[*Aspose.Slides for Python via .NET*](/slides/python-net/) lets you import HTML content into a presentation and export the result as a PDF document. The API provides `SlideCollection.add_from_html` for importing HTML and `Presentation.save` with `SaveFormat.PDF` for creating the output file.

PDF preserves the generated slide layout in a fixed-layout document that is convenient for sharing and printing. This workflow does not require Microsoft PowerPoint or another presentation application.

## Convert HTML to PDF using Python

Create a `Presentation`, remove its default blank slide, import the HTML file, and save the generated slides as a PDF document.

### Python code for converting HTML into PDF

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

    with open("page.html", "rb") as html_stream:
        presentation.slides.add_from_html(html_stream)

    presentation.save("output.pdf", slides.export.SaveFormat.PDF)
```

## How to convert HTML to PDF using Aspose.Slides for Python API

These are the steps to convert HTML to PDF in Python.

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

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

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

Call `Presentation.save` with the output file path and `SaveFormat.PDF`.

## Convert HTML to Other Supported Formats

- [HTML TO IMAGE](/slides/python-net/conversion/html-to-image/)
- [HTML TO JPG](/slides/python-net/conversion/html-to-jpg/)
- [HTML TO PNG](/slides/python-net/conversion/html-to-png/)
- [HTML TO TIFF](/slides/python-net/conversion/html-to-tiff/)
- [HTML TO XML](/slides/python-net/conversion/html-to-xml/)
- [HTML TO PPT](/slides/python-net/conversion/html-to-ppt/)
- [HTML TO PPTX](/slides/python-net/conversion/html-to-pptx/)
