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_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.

Each call returns a report with the counts of shapes, text boxes, pictures and groups, the fonts found, and the SVG or PDF features it could not convert.

Command line

svgslide INPUT... [-o OUTPUT] [--font NAME|OLD=NEW]... [--pages LIST]
         [--merge N|none] [--merge-scope group|touching|figure] [--precision PT]

Each input (.svg, .svgz or .pdf) gives a .pptx next to it, or -o OUTPUT (.pptx or .svg) for a single input. --font sans-serif=Arial replaces one font, a bare --font Arial every font not named, so --font Arial --font "Symbol=Symbol" keeps Symbol. 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.1.0

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.1.0
File Size Uploaded Provenance Actions
svgslide-0.1.0.tar.gz 91.8 kB Without provenance Details for svgslide-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 163.6 kB

Release files / svgslide-0.1.0.tar.gz

Download URL svgslide-0.1.0.tar.gz
Size 91.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4763c0fc8dfc8d34ccb3c44b5fe98909baf2f0b4825429ae31ba615de3134503
BLAKE2b-256 checksum
How to use checksums
d7233cdaf8fae91fd326b8e9bcce8da6968bdd6b375a575bc7d19f7d4ab7e555
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.1.0-py3-none-any.whl

Download URL svgslide-0.1.0-py3-none-any.whl
Size 71.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
557c97243dfad2c481c2e7effb4ba698a914fbdbb84d3af51bcb13d83eb71aa4
BLAKE2b-256 checksum
How to use checksums
cb5ce7aa88ea7092cde91572cfa1a71eba802befea5a5e3518b7b1be912257df
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.1.0

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.1.0 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