Sphinx SVG to PDF or PNG Converter Extension

2.1.0 · active · verified Mon Apr 13

This extension converts SVG images to PDF or PNG when Sphinx builders do not natively support SVG images (e.g., LaTeX). It leverages external tools like Inkscape, rsvg-convert (from libRSVG), or CairoSVG for the conversion. The library is currently at version 2.1.0 and is actively maintained with updates released as needed to support Sphinx versions and conversion tools.

Warnings

Install

Imports

Quickstart

To use `sphinxcontrib-svg2pdfconverter`, you enable one of its backend-specific extensions in your Sphinx project's `conf.py` file. This example uses `cairosvgconverter`, which is often the easiest to set up due to its Pythonic nature, but still requires `libcairo` on the system. Remember to install the `[CairoSVG]` extra for `cairosvg`.

# conf.py
import os
import sys

sys.path.insert(0, os.path.abspath('.'))

project = 'My Sphinx Project'
copyright = '2026, Your Name'
author = 'Your Name'

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinxcontrib.cairosvgconverter', # Choose your backend: inkscapeconverter, rsvgconverter, or cairosvgconverter
]

# Example: Configure path for Inkscape if not in PATH (uncomment and adjust as needed)
# inkscape_converter_bin = '/usr/local/bin/inkscape'

# Example: Configure rsvg-convert (uncomment and adjust as needed)
# rsvg_converter_bin = '/usr/bin/rsvg-convert'
# rsvg_converter_format = 'pdf1.5' # Recommended for LaTeX compatibility

view raw JSON →