svglibwheel


Namesvglibwheel JSON
Version 0.1 PyPI version JSON
download
home_pagehttps://github.com/deeplook/svglib
SummaryA pure-Python library for reading and converting SVG
upload_time2024-04-10 06:49:36
maintainerNone
docs_urlNone
authorDinu Gherman
requires_python>=3.8
licenseLGPL 3
keywords svg pdf reportlab conversion graphics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. -*- mode: rst -*-

======
Svglib
======

---------------------------------------------------------------------------
A pure-Python library for reading and converting SVG
---------------------------------------------------------------------------

.. image:: https://github.com/deeplook/svglib/workflows/CI/badge.svg
  :target: https://github.com/deeplook/svglib/actions?query=workflow%3ACI

.. image:: https://results.pre-commit.ci/badge/github/deeplook/svglib/master.svg
  :target: https://results.pre-commit.ci/latest/github/deeplook/svglib/master
  :alt: pre-commit.ci status

.. image:: https://pyup.io/repos/github/deeplook/svglib/shield.svg
  :target: https://pyup.io/repos/github/deeplook/svglib/

.. image:: https://img.shields.io/pypi/implementation/svglib.svg
  :target: https://pypi.org/project/svglib

.. image:: https://img.shields.io/pypi/pyversions/svglib.svg
  :target: https://pypi.org/project/svglib

.. image:: https://img.shields.io/pypi/dm/svglib.svg
  :target: https://pepy.tech/project/svglib

.. image:: https://img.shields.io/pypi/v/svglib.svg
  :target: https://pypi.org/project/svglib

.. image:: https://img.shields.io/conda/vn/conda-forge/svglib.svg
  :target: https://github.com/conda-forge/svglib-feedstock

.. image:: https://img.shields.io/conda/dn/conda-forge/svglib.svg
  :target: https://github.com/conda-forge/svglib-feedstock

.. image:: https://img.shields.io/conda/pn/conda-forge/svglib.svg
  :target: https://pypi.org/project/svglib

.. image:: https://img.shields.io/pypi/l/svglib.svg
  :target: https://pypi.org/project/svglib

.. image:: https://static.streamlit.io/badges/streamlit_badge_black_white.svg
  :target: https://share.streamlit.io/deeplook/streamlit-svglib/master/streamlit_app.py


About
-----

``Svglib`` is a pure-Python library for reading SVG_ files and converting
them (to a reasonable degree) to other formats using the ReportLab_ Open
Source toolkit.

Used as a package you can read existing SVG files and convert them into
ReportLab ``Drawing`` objects that can be used in a variety of contexts,
e.g. as ReportLab Platypus ``Flowable`` objects or in RML_.
As a command-line tool it converts SVG files into PDF ones (but adding
other output formats like bitmap or EPS is really easy and will be better
supported, soon).

Tests include a huge `W3C SVG test suite`_ plus ca. 200 `flags from
Wikipedia`_ and some selected `symbols from Wikipedia`_ (with increasingly
less pointing to missing features).


Features
--------

- convert SVG_ files into ReportLab_ Graphics ``Drawing`` objects
- handle plain or compressed SVG files (.svg and .svgz)
- allow patterns for output files on command-line
- install a Python package named ``svglib``
- install a Python command-line script named ``svg2pdf``
- provide a PyTest_ test suite with over 90% code coverage
- test entire `W3C SVG test suite`_ after pulling from the internet
- test all SVG `flags from Wikipedia`_ after pulling from the internet
- test selected SVG `symbols from Wikipedia`_ after pulling from the net
- support Python 3.7+ and PyPy3


Known limitations
-----------------

- @import rules in stylesheets are ignored. CSS is supported, but the range
  of supported attributes is still limited
- clipping is limited to single paths, no mask support
- color gradients are not supported (limitation of reportlab)
- SVG ``ForeignObject`` elements are not supported.


Examples
--------

You can use ``svglib`` as a Python package e.g. like in the following
interactive Python session:

.. code:: python

    >>> from svglib.svglib import svg2rlg
    >>> from reportlab.graphics import renderPDF, renderPM
    >>>
    >>> drawing = svg2rlg("file.svg")
    >>> renderPDF.drawToFile(drawing, "file.pdf")
    >>> renderPM.drawToFile(drawing, "file.png", fmt="PNG")

Note that the second parameter of ``drawToFile`` can be any
`Python file object`_, like a ``BytesIO`` buffer if you don't want the result
to be written on disk for example.

In addition a script named ``svg2pdf`` can be used more easily from
the system command-line. Here is the output from ``svg2pdf -h``::

    usage: svg2pdf [-h] [-v] [-o PATH_PAT] [PATH [PATH ...]]

    svg2pdf v. x.x.x
    A converter from SVG to PDF (via ReportLab Graphics)

    positional arguments:
      PATH                  Input SVG file path with extension .svg or .svgz.

    optional arguments:
      -h, --help            show this help message and exit
      -v, --version         Print version number and exit.
      -o PATH_PAT, --output PATH_PAT
                            Set output path (incl. the placeholders: dirname,
                            basename,base, ext, now) in both, %(name)s and {name}
                            notations.

    examples:
      # convert path/file.svg to path/file.pdf
      svg2pdf path/file.svg

      # convert file1.svg to file1.pdf and file2.svgz to file2.pdf
      svg2pdf file1.svg file2.svgz

      # convert file.svg to out.pdf
      svg2pdf -o out.pdf file.svg

      # convert all SVG files in path/ to PDF files with names like:
      # path/file1.svg -> file1.pdf
      svg2pdf -o "%(base)s.pdf" path/file*.svg

      # like before but with timestamp in the PDF files:
      # path/file1.svg -> path/out-12-58-36-file1.pdf
      svg2pdf -o {{dirname}}/out-{{now.hour}}-{{now.minute}}-{{now.second}}-%(base)s.pdf path/file*.svg

    issues/pull requests:
        https://github.com/deeplook/svglib

    Copyleft by Dinu Gherman, 2008-2021 (LGPL 3):
        http://www.gnu.org/copyleft/gpl.html


Dependencies
------------

``Svglib`` depends mainly on the ``reportlab`` package, which provides
the abstractions for building complex ``Drawings`` which it can render
into different fileformats, including PDF, EPS, SVG and various bitmaps
ones. Other dependancies are ``lxml`` which is used in the context of SVG
CSS stylesheets.


Installation
------------

There are three ways to install ``svglib``.

1. Using ``pip``
++++++++++++++++

With the ``pip`` command on your system and a working internet
connection you can install the newest version of ``svglib`` with only
one command in a terminal::

    $ pip install svglib

You can also use ``pip`` to install the very latest version of the
repository from GitHub, but then you won't be able to conveniently
run the test suite::

    $ pip install git+https://github.com/deeplook/svglib


2. Using ``conda``
++++++++++++++++++

If you use Anaconda_ or Miniconda_ you are surely using its respective package
manager, Conda_, as well. In that case you should be able to install ``svglib``
using these simple commands::

    $ conda config --add channels conda-forge
    $ conda install svglib

``Svglib`` was kindly packaged for ``conda`` by nicoddemus_. See here more about
`svglib with conda`_.


3. Manual installation
+++++++++++++++++++++++

Alternatively, you can install a tarball like ``svglib-<version>.tar.gz``
after downloading it from the `svglib page on PyPI`_ or the
`svglib releases page on GitHub`_ and executing a sequence of commands
like shown here::

    $ tar xfz svglib-<version>.tar.gz
    $ cd svglib-<version>
    $ python setup.py install

This will install a Python package named ``svglib`` in the
``site-packages`` subfolder of your Python installation and a script
tool named ``svg2pdf`` in your ``bin`` directory, e.g. in
``/usr/local/bin``.


Testing
-------

The ``svglib`` tarball distribution contains a PyTest_ test suite
in the ``tests`` directory. There, in ``tests/README.rst``, you can
also read more about testing. You can run the testsuite e.g. like
shown in the following lines on the command-line::

    $ tar xfz svglib-<version>.tar.gz
    $ cd svglib-<version>
    $ PYTHONPATH=. py.test
    ======================== test session starts =========================
    platform darwin -- Python 3.7.3, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
    rootdir: /Users/dinu/repos/github/deeplook/svglib, inifile:
    plugins: cov-2.4.0
    collected 36 items

    tests/test_basic.py ............................
    tests/test_samples.py .s.s.s.s

    =============== 32 passed, 4 skipped in 49.18 seconds ================


Bug reports
-----------

Please report bugs on the `svglib issue tracker`_ on GitHub (pull
requests are also appreciated)!
If necessary, please include information about the operating system, as
well as the versions of ``svglib``, ReportLab and Python being used!


.. _SVG: http://www.w3.org/Graphics/SVG/
.. _W3C SVG test suite:
      http://www.w3.org/Graphics/SVG/WG/wiki/Test_Suite_Overview
.. _flags from Wikipedia:
      https://en.wikipedia.org/wiki/Gallery_of_sovereign_state_flags
.. _symbols from Wikipedia:
      https://en.wikipedia.org/wiki/List_of_symbols
.. _ReportLab: https://www.reportlab.com/opensource/
.. _RML: https://www.reportlab.com/software/rml-reference/
.. _svglib issue tracker: https://github.com/deeplook/svglib/issues
.. _PyTest: http://pytest.org
.. _svglib page on PyPI: https://pypi.org/project/svglib/
.. _svglib releases page on GitHub: https://github.com/deeplook/svglib/releases
.. _Python file object: https://docs.python.org/3/glossary.html#term-file-object
.. _Anaconda: https://www.anaconda.com/download/
.. _Miniconda: https://conda.io/miniconda.html
.. _Conda: https://conda.io
.. _svglib with conda: https://github.com/conda-forge/svglib-feedstock
.. _nicoddemus: https://github.com/nicoddemus

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/deeplook/svglib",
    "name": "svglibwheel",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "SVG, PDF, reportlab, conversion, graphics",
    "author": "Dinu Gherman",
    "author_email": "gherman@darwin.in-berlin.de",
    "download_url": null,
    "platform": null,
    "description": ".. -*- mode: rst -*-\r\n\r\n======\r\nSvglib\r\n======\r\n\r\n---------------------------------------------------------------------------\r\nA pure-Python library for reading and converting SVG\r\n---------------------------------------------------------------------------\r\n\r\n.. image:: https://github.com/deeplook/svglib/workflows/CI/badge.svg\r\n  :target: https://github.com/deeplook/svglib/actions?query=workflow%3ACI\r\n\r\n.. image:: https://results.pre-commit.ci/badge/github/deeplook/svglib/master.svg\r\n  :target: https://results.pre-commit.ci/latest/github/deeplook/svglib/master\r\n  :alt: pre-commit.ci status\r\n\r\n.. image:: https://pyup.io/repos/github/deeplook/svglib/shield.svg\r\n  :target: https://pyup.io/repos/github/deeplook/svglib/\r\n\r\n.. image:: https://img.shields.io/pypi/implementation/svglib.svg\r\n  :target: https://pypi.org/project/svglib\r\n\r\n.. image:: https://img.shields.io/pypi/pyversions/svglib.svg\r\n  :target: https://pypi.org/project/svglib\r\n\r\n.. image:: https://img.shields.io/pypi/dm/svglib.svg\r\n  :target: https://pepy.tech/project/svglib\r\n\r\n.. image:: https://img.shields.io/pypi/v/svglib.svg\r\n  :target: https://pypi.org/project/svglib\r\n\r\n.. image:: https://img.shields.io/conda/vn/conda-forge/svglib.svg\r\n  :target: https://github.com/conda-forge/svglib-feedstock\r\n\r\n.. image:: https://img.shields.io/conda/dn/conda-forge/svglib.svg\r\n  :target: https://github.com/conda-forge/svglib-feedstock\r\n\r\n.. image:: https://img.shields.io/conda/pn/conda-forge/svglib.svg\r\n  :target: https://pypi.org/project/svglib\r\n\r\n.. image:: https://img.shields.io/pypi/l/svglib.svg\r\n  :target: https://pypi.org/project/svglib\r\n\r\n.. image:: https://static.streamlit.io/badges/streamlit_badge_black_white.svg\r\n  :target: https://share.streamlit.io/deeplook/streamlit-svglib/master/streamlit_app.py\r\n\r\n\r\nAbout\r\n-----\r\n\r\n``Svglib`` is a pure-Python library for reading SVG_ files and converting\r\nthem (to a reasonable degree) to other formats using the ReportLab_ Open\r\nSource toolkit.\r\n\r\nUsed as a package you can read existing SVG files and convert them into\r\nReportLab ``Drawing`` objects that can be used in a variety of contexts,\r\ne.g. as ReportLab Platypus ``Flowable`` objects or in RML_.\r\nAs a command-line tool it converts SVG files into PDF ones (but adding\r\nother output formats like bitmap or EPS is really easy and will be better\r\nsupported, soon).\r\n\r\nTests include a huge `W3C SVG test suite`_ plus ca. 200 `flags from\r\nWikipedia`_ and some selected `symbols from Wikipedia`_ (with increasingly\r\nless pointing to missing features).\r\n\r\n\r\nFeatures\r\n--------\r\n\r\n- convert SVG_ files into ReportLab_ Graphics ``Drawing`` objects\r\n- handle plain or compressed SVG files (.svg and .svgz)\r\n- allow patterns for output files on command-line\r\n- install a Python package named ``svglib``\r\n- install a Python command-line script named ``svg2pdf``\r\n- provide a PyTest_ test suite with over 90% code coverage\r\n- test entire `W3C SVG test suite`_ after pulling from the internet\r\n- test all SVG `flags from Wikipedia`_ after pulling from the internet\r\n- test selected SVG `symbols from Wikipedia`_ after pulling from the net\r\n- support Python 3.7+ and PyPy3\r\n\r\n\r\nKnown limitations\r\n-----------------\r\n\r\n- @import rules in stylesheets are ignored. CSS is supported, but the range\r\n  of supported attributes is still limited\r\n- clipping is limited to single paths, no mask support\r\n- color gradients are not supported (limitation of reportlab)\r\n- SVG ``ForeignObject`` elements are not supported.\r\n\r\n\r\nExamples\r\n--------\r\n\r\nYou can use ``svglib`` as a Python package e.g. like in the following\r\ninteractive Python session:\r\n\r\n.. code:: python\r\n\r\n    >>> from svglib.svglib import svg2rlg\r\n    >>> from reportlab.graphics import renderPDF, renderPM\r\n    >>>\r\n    >>> drawing = svg2rlg(\"file.svg\")\r\n    >>> renderPDF.drawToFile(drawing, \"file.pdf\")\r\n    >>> renderPM.drawToFile(drawing, \"file.png\", fmt=\"PNG\")\r\n\r\nNote that the second parameter of ``drawToFile`` can be any\r\n`Python file object`_, like a ``BytesIO`` buffer if you don't want the result\r\nto be written on disk for example.\r\n\r\nIn addition a script named ``svg2pdf`` can be used more easily from\r\nthe system command-line. Here is the output from ``svg2pdf -h``::\r\n\r\n    usage: svg2pdf [-h] [-v] [-o PATH_PAT] [PATH [PATH ...]]\r\n\r\n    svg2pdf v. x.x.x\r\n    A converter from SVG to PDF (via ReportLab Graphics)\r\n\r\n    positional arguments:\r\n      PATH                  Input SVG file path with extension .svg or .svgz.\r\n\r\n    optional arguments:\r\n      -h, --help            show this help message and exit\r\n      -v, --version         Print version number and exit.\r\n      -o PATH_PAT, --output PATH_PAT\r\n                            Set output path (incl. the placeholders: dirname,\r\n                            basename,base, ext, now) in both, %(name)s and {name}\r\n                            notations.\r\n\r\n    examples:\r\n      # convert path/file.svg to path/file.pdf\r\n      svg2pdf path/file.svg\r\n\r\n      # convert file1.svg to file1.pdf and file2.svgz to file2.pdf\r\n      svg2pdf file1.svg file2.svgz\r\n\r\n      # convert file.svg to out.pdf\r\n      svg2pdf -o out.pdf file.svg\r\n\r\n      # convert all SVG files in path/ to PDF files with names like:\r\n      # path/file1.svg -> file1.pdf\r\n      svg2pdf -o \"%(base)s.pdf\" path/file*.svg\r\n\r\n      # like before but with timestamp in the PDF files:\r\n      # path/file1.svg -> path/out-12-58-36-file1.pdf\r\n      svg2pdf -o {{dirname}}/out-{{now.hour}}-{{now.minute}}-{{now.second}}-%(base)s.pdf path/file*.svg\r\n\r\n    issues/pull requests:\r\n        https://github.com/deeplook/svglib\r\n\r\n    Copyleft by Dinu Gherman, 2008-2021 (LGPL 3):\r\n        http://www.gnu.org/copyleft/gpl.html\r\n\r\n\r\nDependencies\r\n------------\r\n\r\n``Svglib`` depends mainly on the ``reportlab`` package, which provides\r\nthe abstractions for building complex ``Drawings`` which it can render\r\ninto different fileformats, including PDF, EPS, SVG and various bitmaps\r\nones. Other dependancies are ``lxml`` which is used in the context of SVG\r\nCSS stylesheets.\r\n\r\n\r\nInstallation\r\n------------\r\n\r\nThere are three ways to install ``svglib``.\r\n\r\n1. Using ``pip``\r\n++++++++++++++++\r\n\r\nWith the ``pip`` command on your system and a working internet\r\nconnection you can install the newest version of ``svglib`` with only\r\none command in a terminal::\r\n\r\n    $ pip install svglib\r\n\r\nYou can also use ``pip`` to install the very latest version of the\r\nrepository from GitHub, but then you won't be able to conveniently\r\nrun the test suite::\r\n\r\n    $ pip install git+https://github.com/deeplook/svglib\r\n\r\n\r\n2. Using ``conda``\r\n++++++++++++++++++\r\n\r\nIf you use Anaconda_ or Miniconda_ you are surely using its respective package\r\nmanager, Conda_, as well. In that case you should be able to install ``svglib``\r\nusing these simple commands::\r\n\r\n    $ conda config --add channels conda-forge\r\n    $ conda install svglib\r\n\r\n``Svglib`` was kindly packaged for ``conda`` by nicoddemus_. See here more about\r\n`svglib with conda`_.\r\n\r\n\r\n3. Manual installation\r\n+++++++++++++++++++++++\r\n\r\nAlternatively, you can install a tarball like ``svglib-<version>.tar.gz``\r\nafter downloading it from the `svglib page on PyPI`_ or the\r\n`svglib releases page on GitHub`_ and executing a sequence of commands\r\nlike shown here::\r\n\r\n    $ tar xfz svglib-<version>.tar.gz\r\n    $ cd svglib-<version>\r\n    $ python setup.py install\r\n\r\nThis will install a Python package named ``svglib`` in the\r\n``site-packages`` subfolder of your Python installation and a script\r\ntool named ``svg2pdf`` in your ``bin`` directory, e.g. in\r\n``/usr/local/bin``.\r\n\r\n\r\nTesting\r\n-------\r\n\r\nThe ``svglib`` tarball distribution contains a PyTest_ test suite\r\nin the ``tests`` directory. There, in ``tests/README.rst``, you can\r\nalso read more about testing. You can run the testsuite e.g. like\r\nshown in the following lines on the command-line::\r\n\r\n    $ tar xfz svglib-<version>.tar.gz\r\n    $ cd svglib-<version>\r\n    $ PYTHONPATH=. py.test\r\n    ======================== test session starts =========================\r\n    platform darwin -- Python 3.7.3, pytest-5.0.1, py-1.8.0, pluggy-0.12.0\r\n    rootdir: /Users/dinu/repos/github/deeplook/svglib, inifile:\r\n    plugins: cov-2.4.0\r\n    collected 36 items\r\n\r\n    tests/test_basic.py ............................\r\n    tests/test_samples.py .s.s.s.s\r\n\r\n    =============== 32 passed, 4 skipped in 49.18 seconds ================\r\n\r\n\r\nBug reports\r\n-----------\r\n\r\nPlease report bugs on the `svglib issue tracker`_ on GitHub (pull\r\nrequests are also appreciated)!\r\nIf necessary, please include information about the operating system, as\r\nwell as the versions of ``svglib``, ReportLab and Python being used!\r\n\r\n\r\n.. _SVG: http://www.w3.org/Graphics/SVG/\r\n.. _W3C SVG test suite:\r\n      http://www.w3.org/Graphics/SVG/WG/wiki/Test_Suite_Overview\r\n.. _flags from Wikipedia:\r\n      https://en.wikipedia.org/wiki/Gallery_of_sovereign_state_flags\r\n.. _symbols from Wikipedia:\r\n      https://en.wikipedia.org/wiki/List_of_symbols\r\n.. _ReportLab: https://www.reportlab.com/opensource/\r\n.. _RML: https://www.reportlab.com/software/rml-reference/\r\n.. _svglib issue tracker: https://github.com/deeplook/svglib/issues\r\n.. _PyTest: http://pytest.org\r\n.. _svglib page on PyPI: https://pypi.org/project/svglib/\r\n.. _svglib releases page on GitHub: https://github.com/deeplook/svglib/releases\r\n.. _Python file object: https://docs.python.org/3/glossary.html#term-file-object\r\n.. _Anaconda: https://www.anaconda.com/download/\r\n.. _Miniconda: https://conda.io/miniconda.html\r\n.. _Conda: https://conda.io\r\n.. _svglib with conda: https://github.com/conda-forge/svglib-feedstock\r\n.. _nicoddemus: https://github.com/nicoddemus\r\n",
    "bugtrack_url": null,
    "license": "LGPL 3",
    "summary": "A pure-Python library for reading and converting SVG",
    "version": "0.1",
    "project_urls": {
        "Homepage": "https://github.com/deeplook/svglib"
    },
    "split_keywords": [
        "svg",
        " pdf",
        " reportlab",
        " conversion",
        " graphics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f5ad01ad51a2cbd214d396f7daa3e7811e0a87807dadae0cd074a11eb5784a6e",
                "md5": "e187b7036fddf4fee7705b34a1229f32",
                "sha256": "34580709019289c760da1fe3c89fbdcd9de69a36efa2ec181743daf00c6c14b2"
            },
            "downloads": -1,
            "filename": "svglibwheel-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e187b7036fddf4fee7705b34a1229f32",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 31096,
            "upload_time": "2024-04-10T06:49:36",
            "upload_time_iso_8601": "2024-04-10T06:49:36.818315Z",
            "url": "https://files.pythonhosted.org/packages/f5/ad/01ad51a2cbd214d396f7daa3e7811e0a87807dadae0cd074a11eb5784a6e/svglibwheel-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-10 06:49:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "deeplook",
    "github_project": "svglib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "svglibwheel"
}
        
Elapsed time: 1.36990s