Print an SVG from the command line

command linecupsprintingsvg

How can I print an SVG, already scaled to a4 size, from the command line?
I tried using lpr, but instead the printer just printed out the actual XML of the file, which isn't what I wanted.

Best Answer

Inkscape can convert between various vector graphics formats, including SVG to PDF. Although it's normally a GUI application, it can run in batch mode without an X server available.

inkscape --without-gui --export-pdf=foo.pdf foo.svg
lpr foo.pdf

Or if you want to print directly:

inkscape --without-gui --export-pdf=/dev/stdout foo.svg | lpr

Another possibility is the Apache Batik library. However, although there is a command line tool based on that library, Fop, it doesn't seem to have a way to use SVG input, so you'd have to write a bit of glue code in Java.

Related Question