Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is macOS system printing quicker than Chrome or lpr?

I noticed that printing the exact same pdf file to the exact same printer does not always take the same amount of time:

  • Printing from macOS preview's default printing dialog is very fast.
  • Printing from Chrome browser's built-in print dialog is slower. The printer pauses for a moment after starting the print job.
  • Printing from the command line with lpr has the same effect as printing from Chrome's built-in print dialog.
  • However, switching to the system printing dialog withing Chrome makes things fast again.

My goal is to make printing from the command line with lpr as smooth as from the system's dialog. What could actually make the difference?

lpr -o landscape /path/to/my/file.pdf is my current command. The generated output is as expected, just too slow.

like image 738
sprain Avatar asked May 26 '17 13:05

sprain


1 Answers

Solution pulled up here from comments below:

In my case, I looked at lpoptions -p printerName -l to see all the options and discovered that one of the defaults didn't match my setup. Fixed it with -o paramName=paramValue in my command and it printed smoothly as ever.


Original answer:

If you haven't already, try the following:

  • Specify -H immediate for the lpr command you use, to override any scheduling that might be happening in the CUPS queue itself.
  • Try to specify the -d $printername parameter to override any decisions about which printer to use.

The manpage for lp gives us a little hint as to what may be happening:

CUPS provides many ways to set the default destination. The LPDEST and PRINTER environment variables are consulted first. If neither are set, the current default set using the lpoptions(1) command is used, followed by the default set using the lpadmin(8) command.

And from lpoptions manpage:

~/.cups/lpoptions - user defaults and instances created by non-root users.

/etc/cups/lpoptions - system-wide defaults and instances created by the root user.

Either of these locations may contain settings so check that you don't have any unexpected configuration sitting there.

Re: destination selection:

The selection of destination can probably be sped up somewhat by specifying a default destination using any of the means above. Declaring a default destination and then choosing that named destination with -d when calling lp or lpr seems to be the easiest way but the ENV variables are also quite handy.

You should also use lpoptions to verify the options of your printer, if any are set to less than optimal values. Matching the options you use in the "normal" OSX printer settings here should cause the two printing methods to operate at the exact same speed.

If that doesn't solve your problem the next step would be to find out which raw file formats your printer is the fastest at printing - and then try to emulate this by doing conversion on the command line and pass the converted file to the printer instead (note: lp and lpr both support using STDIN as input). All things being equal, your computer is probably significantly faster at converting than the printer or print server you use, and Preview may be using a similar trick for example to print raw instead of actually passing the PDF file.

like image 70
Claus Due Avatar answered Nov 24 '22 00:11

Claus Due