How do I set print options for lpr command within a Python script?

1.5k Views Asked by At

When I run lpr <filename>.jpg the file prints out boderless (this is what I want).

When I run subprocess.call("/usr/bin/lpr " + tmp.name, shell=True) from a Python program, it prints out with borders.

I also tried to call it with "lpr -o StpBorderless=True -o StpiShrinkOutput=Expand .jpg" with the same borders still being printed.

Output from lpoptions shows the below (StpBorderless=True, and StpiShrinkOutput=Expand should make it borderless I think).

How can I execute lpr from a Python script to use the exact same options as if I executed it from command line?

auth-info-required=none
copies=1
device-uri=usb://Canon/CP800?serial=DH00071100000840
finishings=3
job-hold-until=no-hold
job-priority=50
job-sheets=none,none
marker-change-time=0
number-up=1
printer-commands=none
printer-info='Canon CP800'
printer-is-accepting-jobs=true
printer-is-shared=false
printer-location printer-make-and-model='Canon SELPHY-CP770 - CUPS+Gutenprint v5.2.9'
printer-state=3
printer-state-change-time=1433298534
printer-state-reasons=none printer-type=2134028
printer-uri-supported=ipp://localhost:631/printers/Canon_CP800
StpBorderless=True
StpiShrinkOutput=Expand 
0

There are 0 best solutions below