svglib

An experimental library for reading and converting SVG
Download

svglib Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Dinu Gherman
  • Publisher web site:
  • http://www.dinu-gherman.net/

svglib Tags


svglib Description

An experimental library for reading and converting SVG Svglib is an experimental Python library for reading SVG files and converting them (to a reasonable degree) to other formats using the Open Source ReportLab Toolkit. As a package it reads existing SVG files and returns them converted to ReportLab Drawing objects that can be used in a variety of ReportLab-related contexts, e.g. as Platypus Flowable objects or in RML2PDF. As a command-line tool it converts SVG files into PDF ones.Examples:You can use svglib as a Python package e.g. like in the following interactive Python session:>>> from svglib.svglib import svg2rlg>>> from reportlab.graphics import renderPDF>>>>>> drawing = svg2rlg("file.svg")>>> renderPDF.drawToFile(drawing, "file.pdf")In addition a script named svg2pdf can be used more easily from the system command-line like this (you can see more examples when typing svg2pdf -h):$ svg2pdf file1.svg file2.svgz$ svg2pdf -o "%(basename)s.pdf" /path/file.svgz?Installation:There are two ways to install `svglib`, depending on whether you havethe `easy_install` command available on your system or not.Using `easy_install`+With the `easy_install` command on your system and a working internet connection you can install `svglib` with only one command in a terminal:: $ easy_install svglibIf the `easy_install` command is not available to you and you want to install it before installing `svglib`, you might want to go to the `Easy Install homepage < http://peak.telecommunity.com/DevCenter/EasyInstall >`_ and follow the `instructions there < http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install >`_.Manual installation:Alternatively, you can install the `svglib` tarball after downloading the file ``svglib-0.6.2.tar.gz`` and decompressing it with the following command:: $ tar xfz svglib-0.6.2.tar.gzThen change into the newly created directory ``svglib`` and install `svglib` by running the following command:: $ python setup.py install This will install a Python module file named ``svglib.py`` in the ``site-packages`` subfolder of your Python interpreter and a script tool named ``svglib`` in your ``bin`` directory, usually in ``/usr/local/bin``.Testing:The `svglib` tarball distribution contains a Unittest test suite in the file ``test_svglib.py`` which can be run like shown in the following lines on the system command-line:: $ tar xfz svglib-0.6.2.tar.gz $ cd svglib/src/test $ python test_svglib.py ...... working on wikipedia/Ankh.svg working on wikipedia/Biohazard.svg working on wikipedia/Dharma_wheel.svg working on wikipedia/Eye_of_Horus_bw.svg ---------------------------------------------------------------------- Ran 12 tests in 87.536s OK Here are some key features of "svglib": · 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 Unittest test suite · test on some standard W3C SVG tests available online · test on some Wikipedia sample SVG symbols available online · test on some Wikipedia sample SVG flags available online Requirements: · Python · reportlab


svglib Related Software