Is it possible to print an svg file via image viewer (i.e. eye of gnome) from the command line, or by using lpr?

The underlying problem is that I have a directory with many svg files in it and want to print all of them automatically without having to individually open each file in image viewer and then print using the UI. I don't need to change any print options within eog (the defaults all work fine).

Note that the lpr command doesn't seem to help here - when applied to svg files it just prints out many pages of XML. I would be just as happy with any solution that involves getting lpr to print the image in an svg rather than the XML.


As you have experienced lpr will only print svg files as XML (and thus prints pages filled with text only).

However there is a very simple workaround which is to convert the svg files to something more workable such as png on the fly and then automatically print these generated files. Two steps are required:

Step 1: Install imagemagick:

sudo apt-get install imagemagick

Step 2: As long as you have lp configured correctly with a 'default' printer then run the following loop in a Terminal screen from within the directory containing your svg files:

for i in *.svg
convert "$i" png:- | lpr


This 'loop' accomplishes the following:

  1. Processes each svg file in turn in the directory
  2. Uses the convert utility (part of imagemagick) to produce png files from each and every svg file
  3. Passes each png file to stdout (rather than writing it permanently to disk)
  4. Prints this file using lpr

This tested perfectly on my own system and should run equally well on your system :).

  • Fantastic. Exactly what I was after. Thank you very much. – Colin T Bowers Jun 4 '17 at 23:36
  • @ColinTBowers Great to hear that it all worked out :) – andrew.46 Jun 5 '17 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.