{"id":13448359,"url":"https://github.com/deeplook/svglib","last_synced_at":"2025-05-14T07:08:25.498Z","repository":{"id":14813717,"uuid":"77148264","full_name":"deeplook/svglib","owner":"deeplook","description":"Read SVG files and convert them to other formats.","archived":false,"fork":false,"pushed_at":"2024-12-23T23:54:14.000Z","size":2953,"stargazers_count":339,"open_issues_count":54,"forks_count":79,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-11T02:51:31.838Z","etag":null,"topics":["documents","graphics","pdf","pdf-generation","python","rendering","svg","vector-graphics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deeplook.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-22T13:51:29.000Z","updated_at":"2025-04-06T18:01:34.000Z","dependencies_parsed_at":"2023-01-13T18:08:16.727Z","dependency_job_id":"ba3a9c2d-08f9-4b1b-8f46-4ce806582cdd","html_url":"https://github.com/deeplook/svglib","commit_stats":{"total_commits":361,"total_committers":37,"mean_commits":9.756756756756756,"dds":0.556786703601108,"last_synced_commit":"774224413af53c16f23df76b4edc0c944968bd68"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeplook%2Fsvglib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeplook%2Fsvglib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeplook%2Fsvglib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deeplook%2Fsvglib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deeplook","download_url":"https://codeload.github.com/deeplook/svglib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092776,"owners_count":22013290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["documents","graphics","pdf","pdf-generation","python","rendering","svg","vector-graphics"],"created_at":"2024-07-31T05:01:43.185Z","updated_at":"2025-05-14T07:08:25.461Z","avatar_url":"https://github.com/deeplook.png","language":"Python","readme":".. -*- mode: rst -*-\n\n======\nSvglib\n======\n\n---------------------------------------------------------------------------\nA pure-Python library for reading and converting SVG\n---------------------------------------------------------------------------\n\n.. image:: https://github.com/deeplook/svglib/workflows/CI/badge.svg\n  :target: https://github.com/deeplook/svglib/actions?query=workflow%3ACI\n\n.. image:: https://results.pre-commit.ci/badge/github/deeplook/svglib/master.svg\n  :target: https://results.pre-commit.ci/latest/github/deeplook/svglib/master\n  :alt: pre-commit.ci status\n\n.. image:: https://pyup.io/repos/github/deeplook/svglib/shield.svg\n  :target: https://pyup.io/repos/github/deeplook/svglib/\n\n.. image:: https://img.shields.io/pypi/implementation/svglib.svg\n  :target: https://pypi.org/project/svglib\n\n.. image:: https://img.shields.io/pypi/pyversions/svglib.svg\n  :target: https://pypi.org/project/svglib\n\n.. image:: https://img.shields.io/pypi/dm/svglib.svg\n  :target: https://pepy.tech/project/svglib\n\n.. image:: https://img.shields.io/pypi/v/svglib.svg\n  :target: https://pypi.org/project/svglib\n\n.. image:: https://img.shields.io/conda/vn/conda-forge/svglib.svg\n  :target: https://github.com/conda-forge/svglib-feedstock\n\n.. image:: https://img.shields.io/conda/dn/conda-forge/svglib.svg\n  :target: https://github.com/conda-forge/svglib-feedstock\n\n.. image:: https://img.shields.io/conda/pn/conda-forge/svglib.svg\n  :target: https://pypi.org/project/svglib\n\n.. image:: https://img.shields.io/pypi/l/svglib.svg\n  :target: https://pypi.org/project/svglib\n\n.. image:: https://static.streamlit.io/badges/streamlit_badge_black_white.svg\n  :target: https://share.streamlit.io/deeplook/streamlit-svglib/master/streamlit_app.py\n\n\nAbout\n-----\n\n``Svglib`` is a pure-Python library for reading SVG_ files and converting\nthem (to a reasonable degree) to other formats using the ReportLab_ Open\nSource toolkit.\n\nUsed as a package you can read existing SVG files and convert them into\nReportLab ``Drawing`` objects that can be used in a variety of contexts,\ne.g. as ReportLab Platypus ``Flowable`` objects or in RML_.\nAs a command-line tool it converts SVG files into PDF ones (but adding\nother output formats like bitmap or EPS is really easy and will be better\nsupported, soon).\n\nTests include a huge `W3C SVG test suite`_ plus ca. 200 `flags from\nWikipedia`_ and some selected `symbols from Wikipedia`_ (with increasingly\nless pointing to missing features).\n\n\nFeatures\n--------\n\n- convert SVG_ files into ReportLab_ Graphics ``Drawing`` objects\n- handle plain or compressed SVG files (.svg and .svgz)\n- allow patterns for output files on command-line\n- install a Python package named ``svglib``\n- install a Python command-line script named ``svg2pdf``\n- provide a PyTest_ test suite with over 90% code coverage\n- test entire `W3C SVG test suite`_ after pulling from the internet\n- test all SVG `flags from Wikipedia`_ after pulling from the internet\n- test selected SVG `symbols from Wikipedia`_ after pulling from the net\n- support Python 3.7+ and PyPy3\n\n\nKnown limitations\n-----------------\n\n- @import rules in stylesheets are ignored. CSS is supported, but the range\n  of supported attributes is still limited\n- clipping is limited to single paths, no mask support\n- color gradients are not supported (limitation of reportlab)\n- SVG ``ForeignObject`` elements are not supported.\n\n\nExamples\n--------\n\nYou can use ``svglib`` as a Python package e.g. like in the following\ninteractive Python session:\n\n.. code:: python\n\n    \u003e\u003e\u003e from svglib.svglib import svg2rlg\n    \u003e\u003e\u003e from reportlab.graphics import renderPDF, renderPM\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e drawing = svg2rlg(\"file.svg\")\n    \u003e\u003e\u003e renderPDF.drawToFile(drawing, \"file.pdf\")\n    \u003e\u003e\u003e renderPM.drawToFile(drawing, \"file.png\", fmt=\"PNG\")\n\nNote that the second parameter of ``drawToFile`` can be any\n`Python file object`_, like a ``BytesIO`` buffer if you don't want the result\nto be written on disk for example.\n\nIn addition a script named ``svg2pdf`` can be used more easily from\nthe system command-line. Here is the output from ``svg2pdf -h``::\n\n    usage: svg2pdf [-h] [-v] [-o PATH_PAT] [PATH [PATH ...]]\n\n    svg2pdf v. x.x.x\n    A converter from SVG to PDF (via ReportLab Graphics)\n\n    positional arguments:\n      PATH                  Input SVG file path with extension .svg or .svgz.\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      -v, --version         Print version number and exit.\n      -o PATH_PAT, --output PATH_PAT\n                            Set output path (incl. the placeholders: dirname,\n                            basename,base, ext, now) in both, %(name)s and {name}\n                            notations.\n\n    examples:\n      # convert path/file.svg to path/file.pdf\n      svg2pdf path/file.svg\n\n      # convert file1.svg to file1.pdf and file2.svgz to file2.pdf\n      svg2pdf file1.svg file2.svgz\n\n      # convert file.svg to out.pdf\n      svg2pdf -o out.pdf file.svg\n\n      # convert all SVG files in path/ to PDF files with names like:\n      # path/file1.svg -\u003e file1.pdf\n      svg2pdf -o \"%(base)s.pdf\" path/file*.svg\n\n      # like before but with timestamp in the PDF files:\n      # path/file1.svg -\u003e path/out-12-58-36-file1.pdf\n      svg2pdf -o {{dirname}}/out-{{now.hour}}-{{now.minute}}-{{now.second}}-%(base)s.pdf path/file*.svg\n\n    issues/pull requests:\n        https://github.com/deeplook/svglib\n\n    Copyleft by Dinu Gherman, 2008-2021 (LGPL 3):\n        http://www.gnu.org/copyleft/gpl.html\n\n\nDependencies\n------------\n\n``Svglib`` depends mainly on the ``reportlab`` package, which provides\nthe abstractions for building complex ``Drawings`` which it can render\ninto different fileformats, including PDF, EPS, SVG and various bitmaps\nones. Other dependancies are ``lxml`` which is used in the context of SVG\nCSS stylesheets.\n\n\nInstallation\n------------\n\nThere are three ways to install ``svglib``.\n\n1. Using ``pip``\n++++++++++++++++\n\nWith the ``pip`` command on your system and a working internet\nconnection you can install the newest version of ``svglib`` with only\none command in a terminal::\n\n    $ pip install svglib\n\nYou can also use ``pip`` to install the very latest version of the\nrepository from GitHub, but then you won't be able to conveniently\nrun the test suite::\n\n    $ pip install git+https://github.com/deeplook/svglib\n\n\n2. Using ``conda``\n++++++++++++++++++\n\nIf you use Anaconda_ or Miniconda_ you are surely using its respective package\nmanager, Conda_, as well. In that case you should be able to install ``svglib``\nusing these simple commands::\n\n    $ conda config --add channels conda-forge\n    $ conda install svglib\n\n``Svglib`` was kindly packaged for ``conda`` by nicoddemus_. See here more about\n`svglib with conda`_.\n\n\n3. Manual installation\n+++++++++++++++++++++++\n\nAlternatively, you can install a tarball like ``svglib-\u003cversion\u003e.tar.gz``\nafter downloading it from the `svglib page on PyPI`_ or the\n`svglib releases page on GitHub`_ and executing a sequence of commands\nlike shown here::\n\n    $ tar xfz svglib-\u003cversion\u003e.tar.gz\n    $ cd svglib-\u003cversion\u003e\n    $ python setup.py install\n\nThis will install a Python package named ``svglib`` in the\n``site-packages`` subfolder of your Python installation and a script\ntool named ``svg2pdf`` in your ``bin`` directory, e.g. in\n``/usr/local/bin``.\n\n\nTesting\n-------\n\nThe ``svglib`` tarball distribution contains a PyTest_ test suite\nin the ``tests`` directory. There, in ``tests/README.rst``, you can\nalso read more about testing. You can run the testsuite e.g. like\nshown in the following lines on the command-line::\n\n    $ tar xfz svglib-\u003cversion\u003e.tar.gz\n    $ cd svglib-\u003cversion\u003e\n    $ PYTHONPATH=. py.test\n    ======================== test session starts =========================\n    platform darwin -- Python 3.7.3, pytest-5.0.1, py-1.8.0, pluggy-0.12.0\n    rootdir: /Users/dinu/repos/github/deeplook/svglib, inifile:\n    plugins: cov-2.4.0\n    collected 36 items\n\n    tests/test_basic.py ............................\n    tests/test_samples.py .s.s.s.s\n\n    =============== 32 passed, 4 skipped in 49.18 seconds ================\n\n\nBug reports\n-----------\n\nPlease report bugs on the `svglib issue tracker`_ on GitHub (pull\nrequests are also appreciated)!\nIf necessary, please include information about the operating system, as\nwell as the versions of ``svglib``, ReportLab and Python being used!\n\n\n.. _SVG: http://www.w3.org/Graphics/SVG/\n.. _W3C SVG test suite:\n      http://www.w3.org/Graphics/SVG/WG/wiki/Test_Suite_Overview\n.. _flags from Wikipedia:\n      https://en.wikipedia.org/wiki/Gallery_of_sovereign_state_flags\n.. _symbols from Wikipedia:\n      https://en.wikipedia.org/wiki/List_of_symbols\n.. _ReportLab: https://www.reportlab.com/opensource/\n.. _RML: https://www.reportlab.com/software/rml-reference/\n.. _svglib issue tracker: https://github.com/deeplook/svglib/issues\n.. _PyTest: http://pytest.org\n.. _svglib page on PyPI: https://pypi.org/project/svglib/\n.. _svglib releases page on GitHub: https://github.com/deeplook/svglib/releases\n.. _Python file object: https://docs.python.org/3/glossary.html#term-file-object\n.. _Anaconda: https://www.anaconda.com/download/\n.. _Miniconda: https://conda.io/miniconda.html\n.. _Conda: https://conda.io\n.. _svglib with conda: https://github.com/conda-forge/svglib-feedstock\n.. _nicoddemus: https://github.com/nicoddemus\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeplook%2Fsvglib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeeplook%2Fsvglib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeeplook%2Fsvglib/lists"}