skillfed

svglib

A pure-Python library for reading and converting SVG

svglib v2.2.0 5.9M downloads/30d#2,006 on PyPI373
Copyleft license LGPL-3.0-or-later Active released

What it is and what it does

Svglib is a pure-Python library that reads SVG files (plain or compressed) and converts them into ReportLab Drawing objects. These objects can then be rendered to PDF, EPS, SVG, or bitmap formats. The library handles SVG gradients, conditional rendering, and clip paths, though it has known limitations around CSS imports, mask elements, and ForeignObject support.

You can use it as a Python package to programmatically convert SVG to other formats, or as a command-line tool (svg2pdf) to batch-convert SVG files to PDF from the shell. It supports Python 3.9+ and PyPy3, with dependencies on reportlab, lxml, pillow, cssselect2, and tinycss2.

Use it for:

  • Convert SVG graphics to PDF for document generation or archival
  • Embed SVG images in ReportLab-based PDF reports or Platypus documents
  • Batch-convert SVG files to PDF from the command line using the svg2pdf tool
  • Render SVG to bitmap formats via ReportLab's renderPM backend
  • Build tools that need to programmatically transform vector graphics to print-ready formats

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Svglib reads SVG files and converts them to ReportLab Drawing objects, which can then be rendered to PDF, bitmap, or other formats supported by ReportLab.

Yes. Svglib is actively maintained, has no known vulnerabilities, low install friction, and solves SVG-to-PDF/bitmap conversion well for most common use cases. The LGPL-3.0-or-later license is copyleft, so disclose modifications if you distribute derivatives. Known limitations (no @import, no mask elements, limited CSS) are documented; verify they don't block your specific SVG files.

Install

svglib on PyPI

pip

pip install svglib

uv

uv add svglib

poetry

poetry add svglib

Installing svglib

Before you install

Low install friction: pure Python wheel with five runtime dependencies. Actively maintained as of 2026-08-14 with no known security vulnerabilities.

License in practice

Licensed under LGPL-3.0-or-later (copyleft). You must disclose source code modifications and make the library available under the same license if you distribute derivative works.

Quickstart

pip install svglib

from svglib.svglib import svg2rlg
from reportlab.graphics import renderPDF

drawing = svg2rlg("file.svg")
renderPDF.drawToFile(drawing, "file.pdf")

Requires Python 3.9 or later. Bitmap output requires an additional renderPM backend; PDF output does not.

Verify before relying

  • Whether CSS attribute support covers the specific stylesheets in your SVG files
  • Performance characteristics for large or complex SVG files
  • Behavior when SVG files use unsupported features (@import rules, mask elements, ForeignObject)

Package facts

License LGPL-3.0-or-later (copyleft)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 5 — cssselect2, lxml, pillow, reportlab, tinycss2
Maintenance actively maintained — 0 days since the last release
Last repo commit
First released
Downloads 5,940,849/month — #2,006 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: svglib-2.2.0-py3-none-any.whl

Keywords: PDF, SVG, conversion, graphics, reportlab

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: End Users/DesktopLicense :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)Natural Language :: EnglishOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: DocumentationTopic :: Multimedia :: Graphics :: Graphics ConversionTopic :: PrintingTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Markup :: XMLTopic :: Utilities

Tags

svg to pdf conversionsvg to reportlab drawingsvg file reader pythonconvert svg graphicssvg rendering library
graphics-conversionpdf-generationsvg-processing

More Python Modules packages