Skip navigation links
SVG 2 Vector: 2.0.0

SVG 2 Vector: 2.0.0

A simple tool box to convert SVG graphics to other vector formats, such as EMF and PDF.

See: Description

Packages 
Package Description
de.vandermeer.svg2vector
SVG to vector converter.
de.vandermeer.svg2vector.applications.base
Base of an S2V application, including options, loaders, and properties.
de.vandermeer.svg2vector.applications.fh
S2V application using Apache Batik to load an SVG document and FreeHep graphics libraries for conversion.
de.vandermeer.svg2vector.applications.fh.converters
Properties and converters using Freehep libraries.
de.vandermeer.svg2vector.applications.is
S2V application using a simple loader to load an SVG document and Inkscape for conversion.

A simple tool box to convert SVG graphics to other vector formats, such as EMF and PDF.

Features

Tool box with applications to convert SVG graphivs to other vector formats and some bitmap formats.

Standard options

Standard options are available in all applications. They cover configuration for conversion targets, message handling, input file, names for outoput file(s) and directories, Inkscape layer handline, and other general options. In addition, the applications are using the ExecS package and thus providing help and version information via command line as well.

Help and version

  • general help (usage)

  • detailed help for each command line options

  • version information

Input options

  • read file either as plain text file or as GZIP (.gz) file

  • can process plain SVG or Inkscape SVg files (latter required for layers)

Target

  • set conversion target

  • set text-as-shape conversion option

Message handling

  • set application to quiet mode

  • set application to verbose mode

  • activate warnings, process information, and detailed messages

  • deactivate error messages

Output handling

  • automatically create directories

  • overwrite existing output files

  • keep temporarily created artifacts (files and directories)

Output name handling

  • set output file and/or directory

  • set basename for output files

  • deactivate use of basename for output files

Layer handling

  • process Inkscape layers found in input files

  • process layers if they exist

  • several options for the output file names when using layers

  • switch all layers on for single conversion

Other options

  • simulate conversion, i.e. run but only print messages, do not create any output

s2v-fp options

Converts SVG to vector formats using Apache Batik to load an SVG document and the Freehep libraries for the conversion. Supported target formats are: EMF, PDF, plain SVG (no Inkscape name space). Each target allows to configure:

  • switch on background

  • background color

  • switch off transparancy

  • use cliping

s2v-is options

Converts SVG to vector formats and some bitmap formats using an existing Inkscape installation. Supported target formats are: EMF, PDF, EPS, PS, WMF, plain SVG (no Inkscape name space), and PNG. Other supported options are:

  • set Inkscape executable

  • create temporary SVG files first (as plain SVG or as Inkscape SVG)

  • manual (for optimized EMF generation) or Inkscape object selection handling of layers

  • target specific options as upported by Inkscape:

    • for PDF: set PDF version

    • for PS: set PS level

    • for PNG: set output DPI

Concepts

The main concepts are: application, input, and target.

Application

The SVG2Vector tool provides different applications to convert SVG graphics to target formats. The tool uses the SKB ExecS to launch applications. All applications are registered with the Java class Svg2VectorExecs for easy execution. Once an application is selected for execution, the application specific command line options and processing applies.

Currently supported are:

  • s2v-hp - converting SVG graphics to vector formats using Apache Batik and Freehep libraries

  • s2v-is - converting SVG graphics to vector (and selected bitmap) formats using an existing Inkscape executable

Some standard applications from the ExecS package are also available when using the standard executor:

  • gen-configure - used to configure generated runtime scripts for the application

  • gen-exec-jar-scripts - creates operating system specific start scripts when using the all-in-one executable jar artifact

  • gen-run-scripts - creates run scripts for application installation

Input

The input for each application needs to be a valid SVG file. There are several options for a valid SVG file:

  • Plain SVG as plain text file

  • Plain SVG as GZ compressed file

  • Inkscape SVG as plain text file

  • Inkscape SVG as GZ compressed file

Other SVG variations might work as well, but have not been tested.

Target

The target of a conversion defines the target format and helps to select a target converter. The target implicitely defines the target file extension. The target also allows to identify target-specific conversion options, for instance the PS level for a PS or EPS target.

The application s2v-fh is using Apache Batik for SVG document handling and FreeHep libraries for conversion. This means that specific name spaces from an Inkscape SVG are not processed (largely ignored). The Inkscape Wiki has a page explaining the specific name spaces inkscape and sodipodi: http://wiki.inkscape.org/wiki/index.php/Inkscape_SVG_vs._plain_SVG .

In case the input is generated from Inkscape and s2v-fh has to be used for the conversion, the best practice is to safe the file as Plain SVG with Inkscape. Otherwise, several formatting descriptions (e.g. centered text) will not be converted correctly.

If an Inkscape installation is available, then s2v-is can be used. This will convert all standard targets (such as PDF and PNG) correctly using Inkscape. For EMF conversion, manual layer handling and temporary file creation should be used.

Short User Guide

Using applications from command line

After installation, simply run an application with command line (CLI) options. Input file and target are always required. Some applications have other required CLI options.

Running an application without any option will produce either an error stating which options are required or do nothing. For instance, running s2v-fh without any options:

#s2v-fh
s2v-fh: error parsing command line -> Missing required options: t, f

Use --help for general usage information and --help [option] for detailed help information on a particular option. For instance, running s2v-is with --help target will provide detailed information on the CLI option target:

#s2v-is --help target
CLI option:  -t, --target <TARGET> (required)  -  specifies a conversion target
Description:
target for the conversion Supported targets are: svg, pdf, emf, wmf, ps, eps, png

Assuming there is an input file time-interval-based.svgz in the directory src/test/resources/svg-files, a conversion with layer handling into the output folder target/output-tests/s2v-fh/pdf/layers-index with simple progress information can be realised as follows:

# s2v-fh --create-directories --overwrite-existing -l -i -t pdf -f src/test/resources/svg-files/time-interval-based.svgz -d target/output-tests/s2v-fh/pdf/layers-index -p
s2v-fh: --- processing multi layer, multi file output
s2v-fh: --- creating directories for output
s2v-fh: --- processing layer 00-frame
s2v-fh: --- processing layer 06-xEy
s2v-fh: --- processing layer 01-table
s2v-fh: --- processing layer 10-xSy
s2v-fh: --- processing layer 11-xFy
s2v-fh: --- processing layer 08-xOy
s2v-fh: --- processing layer 07-xMy
s2v-fh: --- processing layer 09-xDy
s2v-fh: --- processing layer 05-xBy
s2v-fh: --- finished successfully

Using applications in Java

The applications can be used in Java by simply creating a String[] with the commands (same as command line) and then calling the execution method executeApplication(…​)`directly. The following code shows an example creating and object for the `s2v-fh application, with a set of command line options, and then executing it.

1
2
3
4
5
6
7
8
9
10
String[] args = new String[]{
        "--create-directories", "--overwrite-existing",
        "--all-layers", "-l", "-i",
        "-t", "pdf",
        "-f", "src/test/resources/svg-files/time-interval-based.svgz",
        "-d", "target/output-tests/s2v-fh/pdf/layers-index",
        "-q"
};
Svg2Vector_FH app = new Svg2Vector_FH();
app.executeApplication(args);

The applications use return codes to provide information about the execution status:

  • 0 means successfull execution

  • >0 means an early exit option (such as --help or --version) was used

  • <0 means an error did occur

User Guide and Examples

A user guide and examples can be found at the project’s home page: http://www.vandermeer.de/projects/skb/java/svg2vector

Resources

Home page

site

Binaries current release

Bintray current release 2.0.0

Binaries all releases

Bintray all releases

Source repository

Github

Maven Central current release

Maven current release 2.0.0

Maven Central all releases

Maven all releases

Skip navigation links
SVG 2 Vector: 2.0.0

Copyright © 2012–2017. All rights reserved.