I have a range of PDF files 1.pdf, 2.pdf, etc. that I would like to merge into one file, with all the PDFs tiled on one page.

Currently, I have tried pdftk to merge these files, but they are put on separate pages:

pdftk 1.pdf 2.pdf ... cat output merged.pdf

Is there a way to, instead, tile the individual PDF files into one master page on merged.pdf?

link|improve this question

57% accept rate
In cases where using a GUI app is OK, a good alternative is pdfsam.org – reinierpost Jan 31 at 11:12
feedback

4 Answers

you can use montage from ImageMagick

$ montage *.pdf merged.pdf

see also http://www.imagemagick.org/script/montage.php

link|improve this answer
feedback

The pdfLaTeX based pdfnup might work for you. If you have lots of pdf-files you may need to make a long pipe of pdfjam or run it several times.

There is also pdfnup in python.

link|improve this answer
feedback

If filenames are in "system specific" order, then pdftk *.pdf cat output merged.pdf should work just fine.

Here is what I mean by "system specific" order.

Example:
I've got 3 files on my Ubuntu 11.04: 1.pdf, 2.pdf, 10.pdf
Files are merged in order: 10.pdf 1.pdf 2.pdf (ls -l returned the same order as in merged file)

Safest naming convention: 0001.pdf, 0002.pdf, etc.

link|improve this answer
As I stated, this command creates a multi-page PDF. As stated in my question, I am looking for the method of using pdftk to make a one-page PDF that contains input PDFs as tiles. – Alex Reynolds Dec 11 '11 at 9:35
Combine my answer with @micke's. I haven't checked whether pdfnup can take name with wildcard (*.pdf) as argument, but you can use pdf generated by pdftk. Check pdfnup or pdfjam with --nup option. – szemek Dec 11 '11 at 16:49
feedback

If you've got a large number of PDFs in one folderstructure, and you've got a TeX-Installation, this script puts all the PDFs recursivly into one large file:

    #!/bin/bash
#
# pdfdir OUTPUT_FILE
#
# produces one big PDF file of all PDF files in .
#
if [ $# -ne 1 ] || [ -z "$1" ]; then
  echo "Syntax: pdfdir OUTPUT_FILE"
  exit 1
fi
FILE="$(echo "$1"|sed -e 's/\.\(pdf\|tex\)$//')"
for F in "$FILE" "$FILE.tex" "$FILE.pdf" "$FILE.aux" "$FILE.log" ; do
  if [ -e "$F" ]; then
    echo "$F exists already."
    exit 2
  fi
done
cat >"$FILE.tex" <<EOF
\documentclass{article}%
\usepackage{pdfpages}%
\usepackage{grffile}%
\listfiles%
\begin{document}%
%\tableofcontents%
EOF
# helper functions
exist_pdf_files () {
  [ $(find -L "$1" -name \*.pdf -o -name \*.PDF -type f 2>/dev/null|wc -l) -eq 0 ] && return 1
  return 0
}
list_directories () {
  find -L "$1" -maxdepth 1 -mindepth 1 -type d 2>/dev/null | sort
}
list_pdf_files () {
  # version with " around filenames:
  #find -L "$1" -maxdepth 1 -mindepth 1 -name \*.pdf -o -name \*.PDF -type f 2>/dev/null | sort | \
  #  sed -e 's/^/\\includepdf[pages=-]{"/; s/$/"}%/'
  # version without " around filenames:
  find -L "$1" -maxdepth 1 -mindepth 1 -name \*.pdf -o -name \*.PDF -type f 2>/dev/null | sort | \
    sed -e 's/^/\\includepdf[pages=-]{/; s/$/}%/'
}
tex_headline () {
    echo "$1" | sed -e 's/_/\\_/g'
}
# current folder (lefel 0):
list_pdf_files . >>"$FILE.tex"
# Bearbeite Ebene 1:
list_directories . | while read -r DIR1; do
  # Are there PDFs in folders below that level?
  exist_pdf_files "$DIR1" || continue
  # Yes ...
  tex_headline "\section{${DIR1##*/}}%"
  # those:
  list_pdf_files "$DIR1"
  # Level 2:
  list_directories "$DIR1" | while read -r DIR2; do
    exist_pdf_files "$DIR2" || continue
    tex_headline "\subsection{${DIR2##*/}}%"
    list_pdf_files "$DIR2"
    # Level 3:
    list_directories "$DIR2" | while read -r DIR3; do
      exist_pdf_files "$DIR3" || continue
      tex_headline "\subsubsection{${DIR3##*/}}%"
      list_pdf_files "$DIR3"
      # Level 4:
      list_directories "$DIR3" | while read -r DIR4; do
        exist_pdf_files "$DIR4" || continue
        tex_headline "\paragraph{${DIR4##*/}}%"
        list_pdf_files "$DIR4"
        # Level 5:
        list_directories "$DIR4" | while read -r DIR5; do
          exist_pdf_files "$DIR5" || continue
          tex_headline "\subparagraph{${DIR5##*/}}%"
          list_pdf_files "$DIR5"
        done
      done
    done
  done
done >>"$FILE.tex"
echo "\end{document}%" >>"$FILE.tex"
echo "Sourcecode to PDF directly [J/n]"
read -r ANSWER
case "$ANSWER" in
[JjYy]) ;;
*) exit 0 ;;
esac
pdflatex "$FILE"
[ $? -eq 0 ] && rm -f "$FILE.aux" "$FILE.log" "$FILE.tex"

I have not written that code, I've got it from a discussion here: http://www.listserv.dfn.de/cgi-bin/wa?A2=ind1201&L=tex-d-l&T=0&P=10771

It is very usefull. I've translated some German comments into English.

Regards, Alexander

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.