Print full page
When you print eps files, they are usually not scaled to fit the full A4 page. This script does this, but uses a rather ugly approach. It first converts the file to a pdf file, and then uses acroread to scale to A4 and ‘print’ into a postscript file. Afterwards, this ps file is sent to the printer using ‘lpr’.
#! /usr/bin/env python
import os,sys
# the names of the possible printers
printerlist = ['rubens','dkos','pssh']
# parse command line
try:
file = sys.argv[1]
printer = sys.argv[2]
except IndexError:
sys.exit('Usage: printpage')
# produce pdf
os.system('epstopdf ' + file + ' --outfile=tmp.pdf')
# produce scaled ps
os.system('acroread -toPostScript -size a4 -expand tmp.pdf')
# produce scaled ps in landscape
#os.system('acroread -toPostScript -size a4 -expand -landscape tmp.pdf')
if printer in printerlist:
print 'printing on %s' % printer
os.system('lpr -P%s tmp.ps' % printer)
else:
sys.exit('Error: wrong printer')
# clean up
os.system('rm -f tmp.pdf tmp.ps')