Hello there,
if anyone's in need to create booklets to be folded, stapled in the middle and be read recursively as a single book as I often do, a python program of mine could be of help.

In other word, suppose to have 325 pages to be splitted into about 10 booklets of 40 pages each, each of them printed on both side of the paper, folded in the middle and grouped all together to re-create the original book (resized).

The syntax for such task isn't straightforward _so_ this little python app (command line program with argument or to be used as module) asks for number of pages and wished number of sheets for each booklet and automatically calculates the best layout according to your preferences and returns a string like to be used with MultiValent as the following:

me@home:~/Desktop$ ./mlv.py
insert input pages (ex. 122): 325
insert sheet number per booklet (ex. 10): 10
Initial Pages: 325
Requested Sheets per Booklet: 10
Pages per Sheet: 4
******************************************
Adjusted Pages: 328
Booklet layout (sheets): [10, 10, 10, 10, 10, 10, 11, 11]
Final string:
java -classpath Multivalent20060102.jar tool.pdf.Impose -verbose -dim 2x1 -paper-size 297x210mm -layout  "40, 1, 38, 3, 36, 5, 34, 7, 32, 9, 30, 11, 28, 13, 26, 15, 24, 17, 22, 19, 80, 41, 78, 43, 76, 45, 74, 47, 72, 49, 70, 51, 68, 53, 66, 55, 64, 57, 62, 59, 120, 81, 118, 83, 116, 85, 114, 87, 112, 89, 110, 91, 108, 93, 106, 95, 104, 97, 102, 99, 160, 121, 158, 123, 156, 125, 154, 127, 152, 129, 150, 131, 148, 133, 146, 135, 144, 137, 142, 139, 200, 161, 198, 163, 196, 165, 194, 167, 192, 169, 190, 171, 188, 173, 186, 175, 184, 177, 182, 179, 240, 201, 238, 203, 236, 205, 234, 207, 232, 209, 230, 211, 228, 213, 226, 215, 224, 217, 222, 219, 284, 241, 282, 243, 280, 245, 278, 247, 276, 249, 274, 251, 272, 253, 270, 255, 268, 257, 266, 259, 264, 261, 352, 309, 350, 311, 348, 313, 346, 315, 344, 317, 342, 319, 340, 321, 338, 323, 336, 325, 334, 327, 332, 329, 330, 331, 328, 333, 326, 335, 324, 337, 322, 339, 320, 341, 318, 343, 316, 345, 314, 347, 312, 349, 310, 351, 262, 263, 260, 265, 258, 267, 256, 269, 254, 271, 252, 273, 250, 275, 248, 277, 246, 279, 244, 281, 242, 283, 220, 221, 218, 223, 216, 225, 214, 227, 212, 229, 210, 231, 208, 233, 206, 235, 204, 237, 202, 239, 180, 181, 178, 183, 176, 185, 174, 187, 172, 189, 170, 191, 168, 193, 166, 195, 164, 197, 162, 199, 140, 141, 138, 143, 136, 145, 134, 147, 132, 149, 130, 151, 128, 153, 126, 155, 124, 157, 122, 159, 100, 101, 98, 103, 96, 105, 94, 107, 92, 109, 90, 111, 88, 113, 86, 115, 84, 117, 82, 119, 60, 61, 58, 63, 56, 65, 54, 67, 52, 69, 50, 71, 48, 73, 46, 75, 44, 77, 42, 79, 20, 21, 18, 23, 16, 25, 14, 27, 12, 29, 10, 31, 8, 33, 6, 35, 4, 37, 2, 39" target.pdf

Please, be easy on me. I'm a very beginner on Python plus I never published anything on sourceforge therefore... here's the python source. Anyone so kind to tell me how to post something and... where?
Following, the program source. I'd love to hear from you.

#!/usr/bin/python

import sys

listBooklet = []
totalPages = 0
finalLayout = []
initialPages = ""
wishedBookletSheets = ""

### Some interface features

if len(sys.argv) > 1:
    if sys.argv[1] == "-v":
        print
        print "MLV, Multivalent Layout Generator, v. 0.1"
        print "Michele Romanini, 2008"
        print
        sys.exit()
       
    if sys.argv[1] == "-h":
        print
        print "usage:"
        print "python mlg.py [number of pages], [sheets per booklet]"
        print
        print "MultivalentXXX.jar as well as the [target] file "
        print "need to be in the same directory"
        print
        sys.exit()
   
    if len(sys.argv) == 3:
        initialPages = eval(sys.argv[1])
        initialPages = initialPages[0]
        wishedBookletSheets = eval(sys.argv[2])

if initialPages == "":
    initialPages = eval(raw_input('insert input pages (ex. 122): '))

if wishedBookletSheets == "":
    wishedBookletSheets = eval(raw_input('insert sheet number per booklet (ex. 10): '))

#temporary fixed stuff
pages_per_sheet = 4

### Program itself...

def pages( input_pages, pages_per_sheet ):
    #add some page numbers to get all pages to be printed
    #4 pages printed for sheet means should be printed 4-8-12-16... pages

    input = int(input_pages)
    resto = input % pages_per_sheet
   
    if resto == 0:
        #can be printed as is
        booklet = input
        return input
    else:
        #needs some extra pages at the end
        booklet =(input/pages_per_sheet)*pages_per_sheet + pages_per_sheet
        return booklet
        # can't be divided

    del input
    del resto
    del booklet

def createBooklet(bookletNumber, bookletSheets, pages_per_sheet, startPage = 0):
    #ex. createBooklet(0, 10, 4, 2)

    #bookletNumber = 0 #0 to unlimited
    #bookletSheets = 10 #number of sheets to be stapled together
    #pages_per_sheet = 4 #number of pages per sheet. A 1-fold letter size sheet contains 4 pages

    pagesBefore = bookletNumber * (bookletSheets*pages_per_sheet)
    if startPage == 0: #undefined
        firstPage =  pagesBefore + 1
    else:
        firstPage = startPage
    lastPage = firstPage + (bookletSheets * pages_per_sheet) - 1
    tempFirst = firstPage
    tempLast = lastPage
    tempSheetNumber = 1

    returnLeftList = []
    returnRightList = []

    while tempSheetNumber < (bookletSheets+1):
        #prepare two list to be returned
        returnLeftList.append(str(tempLast) + ", " + str(tempFirst))
        returnRightList.append(str(tempFirst+1) + ", " + str(tempLast -1))
        #print tempLast, tempFirst, tempFirst + 1, tempLast -1
        tempFirst = tempFirst + 2
        tempLast = tempLast - 2
       
        tempSheetNumber = tempSheetNumber + 1

    del pagesBefore
    del firstPage
    del lastPage
    del tempFirst
    del tempLast
    del tempSheetNumber
   
    return returnLeftList, returnRightList

def bestLayout(inputPages, wishedBookletSheets, pages_per_sheet = 4):
    #return a list[] with best setup

    #inputPages = 1170
    #wishedBookletSheets = 12
    global totalPages
    totalPages = pages(inputPages, pages_per_sheet)
    bookletPages = wishedBookletSheets * pages_per_sheet
    currentIndex = ""

    lastBooklet = totalPages % bookletPages
    global listBooklet
    i = 0

    bookletCount = totalPages / bookletPages
    if totalPages % bookletPages <> 0:
        bookletCount = bookletCount + 1
    listBooklet = [wishedBookletSheets]
    while i < bookletCount - 1:
        #Load Booklet structure
        listBooklet.append(wishedBookletSheets)
        i = i + 1
       
    if lastBooklet <> 0: #last booklet shorter than others
    #   print 'need adjustment for %d pages, %d sheets' % (lastBooklet, lastBooklet / 4)
    #   print 'Recommended layout:'

        i = lastBooklet / pages_per_sheet
        currentIndex = len(listBooklet) - 1

       
        if lastBooklet / pages_per_sheet < wishedBookletSheets / 2: #if smaller than 50%
            del listBooklet[currentIndex]
            currentIndex = currentIndex -1
            while i > 0:
                #adds up pages to previous booklet, preferring last ones
                listBooklet[currentIndex] = listBooklet[currentIndex] + 1
                currentIndex = currentIndex - 1
                i = i - 1
            bestLayout.adjusted = True
        else:
            #TODO: really needed? Adjust last booklet if smaller than 100% but over 50%
            listBooklet[len(listBooklet)-1] = lastBooklet / pages_per_sheet

    del bookletPages
    del lastBooklet
    del i
    del bookletCount
    del currentIndex
   

def overallLayout():
    #merge tuples and return final imposition string
    global finalLayout
    i = 0
    startPage = 0
    returnLeftList = []
    returnRightList = []
    tempSubtuple = []
    tempSubSub = []
    tempSorted = []
    out = ""
   
    while i < len(listBooklet):
        if i > 0:
            startPage= (listBooklet[i-1]*i*pages_per_sheet)+1
        finalLayout.append(createBooklet(i, listBooklet[i], pages_per_sheet, startPage))
        i = i + 1       
       
    #extract data from tuples in the correct order
    #
    i = 0
    o = 0

    #normal order for left pages
    while i < len(listBooklet):
        tempSubtuple = finalLayout[i]
        returnLeftList = returnLeftList + tempSubtuple[0]
        i = i + 1
   
    #reverse order for right pages   
    i = len(listBooklet)
    while i > 0:
        tempSubtuple = finalLayout[i - 1]
        tempSubSub = tempSubtuple[1]
        o = len(tempSubSub)
        while o > 0:
            returnRightList.append(tempSubSub[o-1])
            o = o - 1
        i = i -1
   
    #convert everything into a single string
    #left pages
    i = 0
    while i < len(returnLeftList):
        out = out + ", " + returnLeftList[i] #useless first two chars (, ) dropped later
        i = i + 1
   
    #right pages
    i = 0
    while i < len(returnRightList):
        out = out + ", " + returnRightList[i]
        i = i + 1
   
    out = out[2:] #drop some chars on the left
   
    del finalLayout
    del i
    del startPage
    del returnLeftList
    del returnRightList
    del tempSubtuple
    del tempSubSub
    del tempSorted

    return out

### Output stuff

bestLayout(initialPages,wishedBookletSheets,pages_per_sheet)
print "Initial Pages:", initialPages
print "Requested Sheets per Booklet:", wishedBookletSheets
print "Pages per Sheet:", pages_per_sheet
print "******************************************"
print "Adjusted Pages:", totalPages
print "Booklet layout (sheets):", listBooklet
print "Final string:"
print 'java -classpath Multivalent20060102.jar tool.pdf.Impose -verbose -dim 2x1 -paper-size 297x210mm -layout  "' + overallLayout() + '" target.pdf'

del initialPages
del wishedBookletSheets
del listBooklet
del totalPages
del sys