Skip to main content

svgslide

Convert an SVG drawing or a PDF into a PowerPoint file (.pptx) whose parts are separate, editable PowerPoint objects: shapes you can recolour and resize, real text boxes, pictures, and groups that follow the drawing's groups. Made with scientific figures in mind (Matplotlib, seaborn, ggplot), but works well for most simple vector images (see Limitations).

Pure Python (3.9+). SVG input needs nothing else; PDF input uses the optional pypdfium2.

pip install svgslide          # SVG input
pip install "svgslide[pdf]"   # SVG and PDF input
svgslide figure.svg           # writes figure.pptx

Python

import svgslide

svgslide.convert("figure.svg", "figure.pptx")
svgslide.convert("figure.pdf", "figure.pptx", pages=[1, 3])
svgslide.convert(["a.svg", "b.pdf"], "talk.pptx")   # one deck
svgslide.convert_figure(fig, "figure.pptx")      # a Matplotlib figure

Options (both functions):

  • fonts: replace fonts in the output file, e.g. fonts={"sans-serif": "Arial"}, or fonts="Arial" for every font; in a table, "*" stands for every font not named.
  • pages (PDF): which pages to convert; each page becomes its own slide.
  • merge, merge_scope: shapes that look the same become one shape when there are more than merge of them (default 2000; 0 merges every set, None never). merge_scope says what may merge: "group" (default, within one group of the drawing), "touching" (shapes that overlap or touch) or "figure" (anywhere). Useful for dense scatter plots and genome-browser tracks.
  • precision: round outline coordinates to a grid in points (e.g. 0.01) for smaller files.
  • format: "pptx" or "svg"; a destination ending in .svg writes the converted drawing as SVG, for editors that do not open .pptx.
  • scale: make the whole drawing (text, lines and pictures too) larger or smaller, e.g. scale=2.
  • width, height: the figure's final size instead, e.g. width="20cm" (cm, mm, in, pt, px; a plain number is points); the other side follows.
  • canvas_size: the slide size, with the figure centred on it: "widescreen", "4:3", "A4", "A4-portrait" or e.g. "25cm x 14cm". A larger figure is shrunk to fit.

A list of sources gives one deck: one slide per SVG and per PDF page, each figure at its own size, centred on slides as large as the largest figure.

Each call returns a report with the counts of shapes, text boxes, pictures and groups, the fonts found, the SVG or PDF features it could not convert, and notes such as a figure shrunk to fit.

Command line

svgslide INPUT... [-o OUTPUT] [--font NAME|OLD=NEW]... [--pages LIST]
         [--merge N|none] [--merge-scope group|touching|figure] [--precision PT]
         [--scale F | --width SIZE | --height SIZE] [--canvas-size SIZE]

Each input (.svg, .svgz or .pdf) gives a .pptx next to it, or -o OUTPUT (.pptx or .svg) for a single input; several inputs with -o talk.pptx give one deck. --font sans-serif=Arial replaces one font, a bare --font Arial every font not named, so --font Arial --font "Symbol=Symbol" keeps Symbol. --scale, --width, --height and --canvas-size work as in Python (--width 20cm, --canvas-size widescreen). The fonts found and anything that could not be converted are printed for each file.

What is converted

  • Shapes and paths, with their colours, transparency, line widths, dashes, line ends and gradients; CSS styles; reused symbols and markers.
  • Text as text boxes with font, size, weight, colour, alignment and rotation; text along a curve becomes one text box per letter.
  • Text that a program saved only as letter outlines: Matplotlib and seaborn labels become real text again; Cairo labels (R svg(), pdftocairo) become one shape per label.
  • Embedded PNG, JPEG and GIF images as pictures; rectangular clipping.
  • PDF pages: shapes, text, images and clipping, read with pypdfium2.

Limitations

  • PowerPoint has no clipping for shapes: clipping by a rectangle is applied exactly, any other clip shape only approximately.
  • Not converted (listed in the report): filters such as blur and drop shadows, masks, pattern fills, Inkscape flowed text, animation, external image files; in PDFs, smooth shadings and patterns (patterns become their average colour), soft masks and blend modes.
  • The focal point of radial gradients is ignored.
  • Text from Cairo-made files (R svg(), pdftocairo) cannot become editable text: those files hold letter shapes, not characters.
  • Letter spacing of text along a curve is estimated, so it can differ a little from the original.
  • Fonts are not embedded: PowerPoint uses the named font if it is installed, otherwise a substitute. Use fonts= / --font to pick fonts you have.
  • Merged shapes keep each point's full outline, so a merged .pptx can be larger than an unmerged one, although it has far fewer objects.

Development

python -m venv .venv
.venv/bin/pip install -e ".[pdf]" pytest matplotlib
.venv/bin/python -m pytest

Tests needing pypdfium2 or Matplotlib are skipped without them. SVGSLIDE_CORPUS=/folder/of/svgs adds a smoke test over a folder of SVG files; picture comparison tests run when LibreOffice (soffice) and Inkscape are on PATH.

Licence

MIT. The DrawingML structure follows mpl-office (MIT); see LICENSE.

Metadata

Release files for svgslide 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for svgslide 0.2.1
File Size Uploaded Provenance Actions
svgslide-0.2.1.tar.gz 98.7 kB Without provenance Details for svgslide-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for svgslide 0.2.1
File Interpreter ABI Platform Actions
svgslide-0.2.1-py3-none-any.whl Python 3 none any Details for svgslide-0.2.1-py3-none-any.whl

Total release size: 174.5 kB

Release files / svgslide-0.2.1.tar.gz

Download URL svgslide-0.2.1.tar.gz
Size 98.7 kB
Tags Source
SHA-256 checksum
How to use checksums
46b852576b6e3bc0f0cf87d7350966f4069d183d1bd3f15ca863eddb5da39138
BLAKE2b-256 checksum
How to use checksums
d34cac9e3d9dc854746b34ca11ece90df6697ea5ec058013431ecc04384f6e2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / svgslide-0.2.1-py3-none-any.whl

Download URL svgslide-0.2.1-py3-none-any.whl
Size 75.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb09f493a203ba191da70d0794723fc91aad595487fded0e133aa5b9607fa60e
BLAKE2b-256 checksum
How to use checksums
4efb9d6b9589a8676e758cc27c090280ab75eec29eb7a410347e93a4550c111a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for svgslide 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page