First of, I don't understand your pseudo code. (What does 10*i for i in range(77): mean in this case?)
Generally, you use subprocess.Popen to run external commands. ActiveState recipe 511505 shows an example specifically with lpr. Basically, you can invoke lpr like this:
subprocess.Popen(['lpr', 'some_filename'])
However: Depending on your version of lpr, there may not be an option to select a subset of all pages, or this functionality may be available only for e.g. dvi files.
Edit: Since you seem to want to print selected pages of PDF files, have a look at the PDF toolkit. That software appears to provide splitting functionality. Also, make sure that directly printing PDF files is supported. You may need to convert the input to postscript first (e.g. using pdf2ps). Of course you can automate these tasks using subprocess.Popen as well.
0
Reinout van Rees
On
Just call it from the commandline:
import commands
for i in range(77):
# I'm making no assumptions about lpr command syntax here.
cmd = "lpr --pages(%s,%s) file.pdf" % (2*i, 2*i+1)
commands.getoutput(cmd)
Something like that.
2
niels
On
I haven't tried it, but pycups appears to be python bindings for cups.
First of, I don't understand your pseudo code. (What does
10*i for i in range(77):
mean in this case?)Generally, you use
subprocess.Popen
to run external commands. ActiveState recipe 511505 shows an example specifically withlpr
. Basically, you can invokelpr
like this:However: Depending on your version of
lpr
, there may not be an option to select a subset of all pages, or this functionality may be available only for e.g. dvi files.Edit: Since you seem to want to print selected pages of PDF files, have a look at the PDF toolkit. That software appears to provide splitting functionality. Also, make sure that directly printing PDF files is supported. You may need to convert the input to postscript first (e.g. using
pdf2ps
). Of course you can automate these tasks usingsubprocess.Popen
as well.