All Projects → deeplook → Svglib

deeplook / Svglib

Licence: lgpl-3.0
Read SVG files and convert them to other formats.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Svglib

Svg.skia
An SVG rendering library.
Stars: ✭ 122 (-12.23%)
Mutual labels:  graphics, rendering, vector-graphics, svg
Picasso
Picasso is a high quality 2D vector graphic rendering library. It support path , matrix , gradient , pattern , image and truetype font.
Stars: ✭ 205 (+47.48%)
Mutual labels:  graphics, rendering, vector-graphics, svg
Itext7
iText 7 for Java represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every workflow.
Stars: ✭ 913 (+556.83%)
Mutual labels:  documents, svg, pdf, pdf-generation
Itext7 Dotnet
iText 7 for .NET is the .NET version of the iText 7 library, formerly known as iTextSharp, which it replaces. iText 7 represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every workflow.
Stars: ✭ 698 (+402.16%)
Mutual labels:  documents, svg, pdf, pdf-generation
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (+9.35%)
Mutual labels:  graphics, rendering, svg
Gerbolyze
Render high-resolution bitmap images to PCB gerber files
Stars: ✭ 169 (+21.58%)
Mutual labels:  graphics, vector-graphics, svg
Etherpad Lite
Etherpad: A modern really-real-time collaborative document editor.
Stars: ✭ 11,937 (+8487.77%)
Mutual labels:  documents, pdf, pdf-generation
Php Svg
Vector graphics (SVG) library for PHP
Stars: ✭ 256 (+84.17%)
Mutual labels:  rendering, vector-graphics, svg
Scour
Scour - An SVG Optimizer / Cleaner
Stars: ✭ 443 (+218.71%)
Mutual labels:  graphics, vector-graphics, svg
Macsvg
macSVG - An open-source macOS app for designing HTML5 SVG (Scalable Vector Graphics) art and animation with a WebKit web view ➤➤➤
Stars: ✭ 789 (+467.63%)
Mutual labels:  graphics, vector-graphics, svg
Openhtmltopdf
An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
Stars: ✭ 1,096 (+688.49%)
Mutual labels:  svg, pdf, pdf-generation
Pdf Lib
Create and modify PDF documents in any JavaScript environment
Stars: ✭ 3,426 (+2364.75%)
Mutual labels:  pdf, pdf-generation, documents
One File Pdf
A minimalist Go PDF writer in 1982 lines. Draws text, images and shapes. Helps understand the PDF format. Used in production for reports.
Stars: ✭ 429 (+208.63%)
Mutual labels:  graphics, pdf, pdf-generation
Vectorgraphics2d
Graphics2D implementations to export various vector file formats
Stars: ✭ 87 (-37.41%)
Mutual labels:  svg, pdf, pdf-generation
Graphicsrenderer
A drop-in UIGraphicsRenderer port -- CrossPlatform, Swift 4, Image & PDF
Stars: ✭ 85 (-38.85%)
Mutual labels:  graphics, rendering, pdf
Dvisvgm
A fast DVI, EPS, and PDF to SVG converter
Stars: ✭ 134 (-3.6%)
Mutual labels:  vector-graphics, svg, pdf
Pixelfarm
From Vectors to (sub) Pixels, C# 2D Rendering Library
Stars: ✭ 120 (-13.67%)
Mutual labels:  vector-graphics, svg
Labelmake
Declarative style JavaScript PDF generator library. Works on Node and the browser 🖨︎
Stars: ✭ 112 (-19.42%)
Mutual labels:  pdf, pdf-generation
Rad Lines
Beautiful Vector Generator Tool
Stars: ✭ 121 (-12.95%)
Mutual labels:  vector-graphics, svg
Bgrabitmap
📜 BGRABitmap graphics library made with Lazarus (Free Pascal).
Stars: ✭ 112 (-19.42%)
Mutual labels:  graphics, svg

.. -- 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://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

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.6+ and PyPy3

Known limitations

  • support for stylesheets is still experimental. Please report any bug or shortcoming on the svglib issue tracker_.
  • clipping is limited to single paths, no mask support
  • color gradients are not supported (limitation of reportlab)

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

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].