Printing booklet, 2 side 2 sheet xubuntu 14

print_booklet-with-evince

Here is my python script to successfully print booklet.

  1. thanks to : http://askubuntu.com/questions/214538/printing-in-booklet-format

page = 8 # how many page do you have? minimum is 1
start = 35 # book start from page? 3-18, 19-34, 35-66
p = []
for i in range( page*4) :
  p.append( i+start )

l = (len( p ) / 4)
dl = len(p)-1
out = ""
for a in range( l ) :
out = out + str(p[dl-a*2]) + "," + str(p[a*2]) + "," + str(p[a*2+1]) + "," + str(p[dl-a*2-1]) +","

print out[:-1] # ommit last comma

# array to check wether that algorithm accurate
def confirm() :
  v4 = [ 4,1,2, 3 ]
  v8 = [ 8,1,2, 7, 6,3,4, 5 ] # booklet 8 pages, 2 sided, 2 sheet per page
  v16 = [16,1,2,15, 14,3,4,13, 12,5,6,11, 10,7,8,9 ]
  v32 = [32,1,2,31, 30,3,4,29, 28,5,6,27, 26,7,8,25, 24,9,10,23, 22,11,12,21, 20,13,14,19, 18,15,16,17]

  s8 = [ 1,2,3,4, 5,6,7,8 ] # sorted
  s16 = [ 1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16 ] # sorted
  s32 = [ 1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16, 17,18,19,20, 21,22,23,24, 25,26,27,28, 29,30,31,32 ] # sorted