How to stitch multiple PDF pages into one large PDF file, like a canvas?

I have a 32-page PDF file of my family tree. Instead of having a family tree on one really large PDF page (this is what I want), it is formatted, so it is assumed that a group of 8 separate pages with the US alphabet should be stitched in width; 4 lines of this complete the tree. The margins of each page are 22px.

If you render it in a table (where numbers represent the page numbers of a PDF):

table

I tried hacking Python code for this, but not very far. How can I stitch a PDF file so that it can be one large page instead of small separate pages?

Thanks for the help.

EDIT: Here is the code I wrote. Sorry for not 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() 
+8
python pdf pdflatex
source share
3 answers

As an alternative to Ben Jackson's suggestion of first converting to PostScript and performing the "N-up" conversion in PostScript files, there is also a utility called pdfnup available as part of PDFjam , which can work directly in PDF files. Example:

 pdfnup --nup 8x4 --outfile output.pdf input.pdf 
+3
source share

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

The link sample combines the perl script to modify PostScript to insert some snippets, but you can find more complex examples that override the showpage so you can simply insert your preamble with an overridden showpage at the beginning of your document.

+1
source share

If you have a LaTeX installation, I would recommend using

  • pdfpages package
  • a little 10-line LaTeX script / document,
  • and pdflatex .

LaTeX script

Save the following LaTeX script as 8x4-letter.tex . Adapt /path/to/input.pdf accordingly:

 \documentclass{article} \usepackage{color} \definecolor{mygray}{rgb}{.9,.9,.9} % background color for complete poster \pagecolor{mygray} % line must *precede* \usepackage{pdfpages} \usepackage[final]{pdfpages} % comment out for testing \usepackage[paperwidth=4896ppt, paperheight=3168]{geometry} % dimensions of 8 letter widths, 4 heights \pagestyle{plain} % do not use page numbering \begin{document} % orig. slide sizes are 612x792 pts (Letter) \includepdf[nup=8x4, % 8x4 grid was asked for delta=0 0, % horiz.+vert. distance between slides scale=0.999, % scale down for additional margins pages={1-32}, % input document has 32 pages noautoscale=false, % set to true if you have larger pages frame=false] % set to true if you want frames {/path/to/input.pdf} % filename+path cannot have spaces! \end{document} 

pdflatex command

Now run

 pdflatex 8x4-letter.tex 

This should result in the creation of a PDF file, 8x4-lettter.pdf .

If you need frames around each page, use frame=true . To add extra page spacing, use delta=10 10 or delta=17 11 or whatever suits you. You can also change the value for scale=...

0
source share

All Articles