Go to page:

Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

UseBatikSVGImages

Categories: Tips, Software
<< | Page list | >>

Include SVG Images in LyX

The are two possibilities these days. One based on Inkscape and new one based on Apache Batik. Please read details below about second of these two techniques.

Apache Batik

Apache Batik from http://xmlgraphics.apache.org/batik can be used to configure LyX to directly include SVG images. Batik produces high quality PDF and PGN files but it currently cannot generate EPS. Make sure you have a "lossless" (vector to vector) PDF -> EPS converter defined, as described below.

This solution requires working Java Virtual Machine. It is slower than method with Inkscape described below, but circumvents Inkscape SVG incompatibilities (and does not require Inkskape, of course).

If you encounter problems with Inkspace messing up gradients, batik solves the problems just fine.

Please note: batik bases the size of the output graphics file, be it PNG or PDF, on the height and width attributes of the SVG element in the SVG file. If these are not present, batik assumes a default rectangle area, circa 400px by 400px. To work around the issue with buggy SVG files (for example diagrams produced by eUML), please provide the necessary attributes by hand-editing the files. One could find the dimensions with a cursor in the batik editor.

Windows

You can configure LyX in a few steps:

  • Download and uncompress Apache Batik
  • Copy the script(s) from SVG Files and Batik into your LyX scripts directory and change the BATIK_DIR variable in the script(s) to point directory where Batik files are lying.
  • Adopt your LyX Preferences as follows:
    • In the Section Paths add to Path-Prefix the directory where the above scripts are located.
    • In the Section File Formats
      • Fill in the text fields with the following values
        Format: svg
        GUI-Name: SVG
        Extention: svg
        Viewer: batik SHOW $$i
        Editor: leave empty (or add inkscape, if it is installed)
      • Make sure the Vector graphics format checkbox is checked.
      • Important: Press Add
    • In the Section Converters
      • Fill in the fields with the following values
        From: SVG
        To: PDF (pdflatex)
        Converter: batik PDF $$i $$o
      • Important: Press add
      • Fill in the fields with the following values
        From: SVG
        To: PNG
        Converter: batik PNG $$i $$o
    • In the Section Converters (optional, if you need EPS)
      • Fill in the fields with the following values
        From: PDF (ps2pdf)
        To: EPS
        Converter: pdftops -eps -f 1 -l 1 $$i $$o
      • Important: Press add
      • Fill in the fields with the following values
        From: PDF (dvipdfm)
        To: EPS
        Converter: pdftops -eps -f 1 -l 1 $$i $$o
      • Important: Press add
    • Press Save

You need to restart and maybe reconfigure LyX.

Linux

A really similar approach to the one on Windows. Please see SVG Files and Batik for a bash script.

Hints

refer to
On Feb 20, 2009 author moved Batik related information to separate page. Please refer to hints for Inkscape.
memory problems
On Feb 20, 2009 memory problem with batik-rasterizer and large SVG files has been found. Please increase value given in JAVA_MEM variable, by correcting -Xmx128s option for jvm (this option is related to Sun's product only, I think).

Categories

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2010-01-24 21:56 CET