How to stitch several PDF pages into one big canvas-like PDF?

I have a 32-page PDF of my family tree. Instead of having the family tree all on one really big PDF page (which is what I want), it is formatted so a group of 8 individual US letter-sized pages are supposed to be stitched across the width; 4 rows of this completes the tree. The margins of each page are all 22px.

If you visualize it in table form (where the numbers represent PDF page numbers):

table

I've tried to whip up some Python code to do this, but haven't gotten very far. How can I stitch the PDF so it can be one big page instead of smaller individual pages?

Thanks for the help.

EDIT: Here's the code I wrote. Sorry for not originally posting it.

from pyPdf import PdfFileWriter, PdfFileReader

STITCHWIDTH = 8;
currentpage = 1;

output = PdfFileWriter()
input1 = PdfFileReader(file("familytree.pdf", "rb"))

for(i=0; i<=4; i++)
    output.addPage(input1.getPage(currentpage))
    currentpage++;
    #do something to add other pages to width

print "finished with stitching"

outputStream = file("familytree-stitched.pdf", "wb")
output.write(outputStream)
outputStream.close()

As an alternative to Ben Jackson's suggestion of first converting to PostScript, and doing a "N-up" transform on the PostScript files, there's also a utility called pdfnup available as part of the PDFjam suite, that can operate directly on PDF files. Example:

pdfnup --nup 8x4 --outfile output.pdf input.pdf

Use pdf2ps (part of Ghostscript) to convert the PDF to PostScript. This is usually a lossless transformation. Then use the techniques of http://www.tailrecursive.org/postscript/nup.html or any other "N-up" PostScript preamble to reorganize your pages.

The sample link combines a perl script to modify the PostScript to insert some snippets, but you can find more sophisticated examples which override showpage so that you can just insert your preamble with the redefined showpage at the start of your document.