I am able to print from Inkscape to my CUPS-configured network printer just fine. I would like to do the same directly from the shell command line as given by the https://unix.stackexchange.com/a/12002/21372 answer. But when I try that on my Ubuntu system, after I convert the SVG files to either PDF or Postscript using Inkscape, sending it to lpr
gives the error shown below on the front panel of the printer (a Xerox 6180MFP):
Commands I'm trying to use are:
inkscape --without-gui --export-pdf=test_file.pdf test_file.svg
pdftops test_file.pdf test_file.ps
lpr -P Xerox-6180MFP-D -l test_file.ps
What do I need to do to my CUPS configuration to enable it? What is Inkscape doing behind the scenes to successfully print to the printer, that I am unable to do from the lpr
command line?
For reference, here is a gist of my current CUPS configuration file: https://gist.github.com/bgoodr/6f8b47df40244fed6290a6a199e72c52
Output of lpstat -t
:
scheduler is running
no system default destination
device for Xerox-6180MFP-D: socket://192.168.1.20
device for Xerox-6180MFP-D/double-sided: socket://192.168.1.20
device for Xerox-6180MFP-D/single-sided: socket://192.168.1.20
Xerox-6180MFP-D accepting requests since Sat 04 Mar 2017 05:36:44 PM PST
Xerox-6180MFP-D/double-sided accepting requests since Sat 04 Mar 2017 05:36:44 PM PST
Xerox-6180MFP-D/single-sided accepting requests since Sat 04 Mar 2017 05:36:44 PM PST
printer Xerox-6180MFP-D is idle. enabled since Sat 04 Mar 2017 05:36:44 PM PST
printer Xerox-6180MFP-D/double-sided is idle. enabled since Sat 04 Mar 2017 05:36:44 PM PST
printer Xerox-6180MFP-D/single-sided is idle. enabled since Sat 04 Mar 2017 05:36:44 PM PST
Screenshot of my printer page at http://localhost:631/printers/Xerox-6180MFP-D
EDIT #1
In response to a comment at How to print PDF or Postscript files to printer directly from the command line :
Here is the script I used to run lpr both with and without the -l
option (shown below without it):
cd /tmp
qrencode -v 1 -t svg -o some_small_text.qrcode.svg -l L "some small text"
inkscape --without-gui --export-pdf=some_small_text.qrcode.pdf some_small_text.qrcode.svg
# setsid evince some_small_text.qrcode.pdf >/dev/null 2>&1 &
pdftops some_small_text.qrcode.pdf some_small_text.qrcode.ps
lpr -P Xerox-6180MFP-D some_small_text.qrcode.ps
Here is a gist of the Postscript file generated from the above call to qrencode:
https://gist.github.com/bgoodr/8411fe6815522490857765e3c28eaad8
The "Load Tray" error leads me to believe I have to specify some more things to the lpr command, or modify some of the options. Somehow Inkscape is able to communicate its needs from the print dialog it requires me to interact with, and it is that I desire to replicate from the lpr
command line.
EDIT #2
I ran lpr
without options and got:
$ echo stuff | lpr
lpr: Error - no default destination available.
EDIT #3
I have partially solved the riddle of where the "Load Tray 1(MPT) ... 76x127mm" error on the front panel of the printer is coming from. When I opened up the Inkscape GUI, and examined the properties on the .svg file generated by the qrencode
command shown above, I see:
Notice the width and height. When I tried to print that using the GUI, I got the same "Load Tray 1(MPT) ... 76x127mm" error! So, I then selected "US Letter" from the Page Size section, and then attempted to print it to the printer, and it worked without a hitch.
So, apparently what is happening is that the printer is seeing this small (in width and height) postscript file and assuming it needs to select a 3 x 5 inch envelope tray. I reason that from looking at page 69 from http://download.support.xerox.com/pub/docs/6180MFP/userdocs/any-os/en/user_guide_en.pdf which has:
So I am a bit closer to the answer to my original question. I just now need a way to be able to choose the Paper Source or change the size from the command line. I've looked at the inkscape
man page, and it is not obvious which options are the ones I should play with. Or perhaps this is an imagemagick/convert type of operation.
This is what I had to do:
The key is that I had to change the
width
,height
, andviewBox
attributes of thesvg
element to match up with what Inkscape does when you select US Letter. The values used for theviewBox
remain a mystery to me. Once I did that, then the resulting PDF, when sent to the printer, kept the printer happy.This is not exactly what I wanted, since in this approach, I have to use
sed
to modify the attributes. I would have rather found a way to use Inkscape to do this on the svg directly. I do see that Inkscape has a-verb
option and a verb calledDialogDocumentProperties
in http://how-to.wikia.com/wiki/How_to_use_Inkscape_in_commandline_mode/List_of_verbs but it is not apparent how to actually select the "US Letter" size using that option.