lpr - macOS


Overview

lpr is a macOS command used to submit print jobs to a printer. It provides options to specify the printer, print quality, and other parameters related to the print job.

Syntax

lpr [-P printer] [-# num] [-i] [-o option] [-m] [-s] [-w] file(s)

Options/Flags

  • -P printer: Specifies the printer to use. If not specified, the default printer will be used.
  • -# num: Specifies the number of copies to print. Default is 1.
  • -i: Interactive mode. Prompts for additional information before printing.
  • -o option: Specifies print options. Common options include:
    • -o media=type: Paper size and type
    • -o orientation=portrait/landscape: Page orientation
    • -o resolution=dpi: Print resolution
  • -m: Mail output to specified email address instead of printing.
  • -s: Silent mode. Suppresses informational messages.
  • -w: Waiting mode. Waits for the printer to be available before printing.

Examples

Example 1: Print a file to the default printer:

lpr myfile.pdf

Example 2: Print multiple copies to a specific printer:

lpr -P HP-Printer -# 3 myfile.doc

Example 3: Print with custom options:

lpr -P HP-Printer -o media=A4 -o orientation=landscape myimage.jpg

Common Issues

  • Permission denied: Ensure you have the necessary permissions to use the specified printer.
  • Printer not found: Check if the printer is connected and turned on.
  • Syntax errors: Carefully check the syntax and ensure all options and arguments are entered correctly.

Integration

lpr can be combined with other commands for advanced tasks:

  • lpr | lpq: Check the status of the print queue.
  • lprm job-id: Cancel a specific print job using its job ID.
  • lp: Lists available printers and their status.
  • lpq: Displays the print queue and job status.
  • lprm: Cancels print jobs.
  • CUPS website