Convert PDF to SVG in Python

Import PDF pages and render them as scalable vector graphics with a cross-platform Python library

Convert PDF to SVG in Python

Aspose.Slides for Python via .NET lets you convert PDF pages to SVG images programmatically. The API imports each PDF page as a slide with SlideCollection.add_from_pdf, then renders each slide by using Slide.write_as_svg.

SVG is a vector format, so every PDF page is written to a separate scalable image file. The conversion requires no Microsoft PowerPoint, Adobe Acrobat, or other presentation software.

Convert PDF to SVG using Python

Create a Presentation, remove its default blank slide, import the PDF pages with SlideCollection.add_from_pdf, and call Slide.write_as_svg for each slide.

Python code for converting PDF into SVG

with slides.Presentation() as presentation:
    presentation.slides.remove_at(0)
    presentation.slides.add_from_pdf("document.pdf")

    for slide in presentation.slides:
        file_path = f"slide_{slide.slide_number}.svg"
        with open(file_path, "wb") as output_stream:
            slide.write_as_svg(output_stream)

How to Convert PDF to SVG Using Aspose.Slides for Python

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

  1. Install Aspose.Slides for Python via .NET .

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

  3. Import the source PDF by using SlideCollection.add_from_pdf.

  4. Access each slide through a Slide variable and call Slide.write_as_svg with an output stream.

Convert PDF to Other Supported Formats

You can also convert PDF and save it in other file formats. See the supported formats below: