# Convert Image to PDF in Python

> Convert images to PDF in Python. Use the Aspose.Slides Python API to place an image on a slide and export it as a PDF document.

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



## Convert Image to PDF in Python

[*Aspose.Slides for Python via .NET*](/slides/python-net/) lets you place a raster image on a slide and export the presentation as a PDF document. Add the image to `Presentation.images`, create a picture frame with `ShapeCollection.add_picture_frame`, and call `Presentation.save` with `SaveFormat.PDF`.

The example below creates a one-page PDF whose page size matches the source image. This workflow preserves the image's aspect ratio and does not require Microsoft PowerPoint or a PDF printer.

## Convert an Image to PDF Using Python

Create a `Presentation`, add the source image to its first `Slide`, and save the presentation as a PDF document.

### Python code for converting an image to PDF

```python
with slides.Presentation() as presentation:
    slide = presentation.slides[0]

    with slides.Images.from_file("image.png") as source_image:
        presentation_image = presentation.images.add_image(source_image)

    presentation.slide_size.set_size(
        presentation_image.width,
        presentation_image.height,
        slides.SlideSizeScaleType.DO_NOT_SCALE,
    )

    slide.shapes.add_picture_frame(
        slides.ShapeType.RECTANGLE,
        0,
        0,
        presentation_image.width,
        presentation_image.height,
        presentation_image,
    )
    presentation.save("image.pdf", slides.export.SaveFormat.PDF)
```

## How to Convert an Image to PDF Using the Aspose.Slides Python API

Follow these steps to convert an image to PDF in Python.

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

Create a `Presentation` and access its first `Slide`.

Load the source image with `Images.from_file`, add it to `Presentation.images`, and use its dimensions for the slide and picture frame.

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

## Convert Images to Other Supported Formats

- [IMAGE TO JPG](/slides/python-net/conversion/image-to-jpg/)
- [IMAGE TO PPT](/slides/python-net/conversion/image-to-ppt/)
- [IMAGE TO PPTX](/slides/python-net/conversion/image-to-pptx/)
