0

I have searched everywhere for this and could not find an answer. I am using os.system to print to a printer, but it prints it off as a portrait and I need it to print off as Landscape. I assume there is a simple way to add something within the os.system command to get this to work, but I cannot figure out what it is. This is how I am printing it off right now:

os.system('lp "file.png"')

2 Answers 2

1

Try os.system('lp -o landscape "file.png"')

Sign up to request clarification or add additional context in comments.

4 Comments

I tried that, however, all it did was shift the image to the right side of the page. I also tried os.system('lpr -o landscape "file.png"').
Hmm, anything strange in the options if you use lpoptions -l?
The only thing that sticks out is the "Rotate/180 Rotate:" is marked as false instead of true. I would think if that would be true it would print properly? Outside of that, everything seems normal.
Turns out it was a bug in the printer software. I reverted it to a previous version and the -o landscape worked. Thanks!
0

Ok it was a bug, but just a hint on convenience:

I usually replace os.system with the following snippet

from subprocess import (PIPE, Popen)


def invoke(command):
    '''
    Invoke process and return its output.
    '''
    return Popen(command, stdout=PIPE, shell=True).stdout.read()

or if you want to be more comfortable with sh, try

from sh import lp

lp('-o', 'landscape', 'file.png')

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.