<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Jan 14, 2012, at 7:30 AM, Juan Luis Varona wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Try the package pdfpages to joint pdf file (with pdflatex):<br><br>\documentclass[11pt]{article}<br><br>\usepackage{pdfpages}<br><br>\title{Brief Article}<br>\author{The Author}<br><br>\begin{document}<br><br>\maketitle<br><br>Hello<br><br>%\newpage<br><br>\includepdf[fitpaper=true]{a-pdf-with-different-size.pdf}<br><br>%\newpage<br><br>Hello<br><br>\end{document} <br><br>---<br><br>Yours,<br><br>Juan Luis<br><br></div></blockquote></div><br><div>Hi,</div><div>as an extension of this, the script below should do the trick. If there are problems with line breaks in the pasted code, you may want to copy it from my web page instead:</div><div><a href="http://pages.uoregon.edu/noeckel/computernotes/latex/n-up.html">http://pages.uoregon.edu/noeckel/computernotes/latex/n-up.html</a></div><div>After saving this in a file, e.g., "~/bin/pdfnup2" and making it executable by typing "chmod 700 ~/bin/pdfnup2" you can get the concatenation of files with their dimensions intact by typing "~/bin/pdfnup -o outputfile.pdf file1.pdf file2.pdf" </div><div>where outputfile.pdf is the desired output name, and file1 etc are an arbitrary number of input files with arbitrary dimensions. </div><div><br></div><div>Hope this helps,</div><div>Jens</div><div><br></div><div><br></div><div><div><span class="Apple-style-span" style="color: rgb(0, 0, 139); font-family: monospace; font-size: 15px; font-weight: bold; white-space: pre; "><br></span></div><div><span class="Apple-style-span" style="color: rgb(0, 0, 139); font-family: monospace; font-size: 15px; font-weight: bold; white-space: pre; ">#!/bin/tcsh</span></div></div><div><pre style="padding-top: 1em; padding-bottom: 1em; color: rgb(0, 0, 0); font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="comment" style="color: rgb(0, 0, 139); font-weight: bold; ">#
# Save this file under any name (e.g., pdfnup2) and make it executable in your PATH.
# Usage instructions are displayed when invoking the command without arguments.
#
# Created Oct 11, 2007 by J.U.Noeckel (originally called pdfbgcolor, only used to change background color)
# Modified March 30, 2009 by J.U.Noeckel (added n-up functionality because no such tool seemed to exist for Leopard)
</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">alias</span> printHelp '<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">printf "Usage: "`basename $0`" [-o outputfile] [-c HTML-color] [-n ROWSxCOLUMNS] [-d DELTA_XxDELTA_Y] filename(s)\n\n";\\</span>
<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; "> printf "outputfile:\n"; \\
printf "name of the output PDF file (default: converted.pdf)\n"; \\
printf "HTML-color:\n"; \\
printf "hexadecimal RGB number in capitals, RRGGBB\n"; \\
printf "The background of the file filename is changed to color HTML-color\n"; \\
printf "Default color: white\n\n";\\
printf "ROWSxCOLUMNS:\n"; \\
printf "two integers separated by x specifying the number of rows and columns to\nprint per physical page (e.g., 2x2)\n\n"; \\
printf "DELTA_XxDELTA_Y:\n"; \\
printf "two floats separated by x sepcifying the offset in points between rows and\ncolumns (may be negative)\n\n"; \\
printf "Output PDF is written to filename-converted.pdf\n"</span>'
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">alias</span> cleanup '<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">rm -Rf $TMPNAME*</span>'
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">if</span> ("<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">$#</span>" == 0) <span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">then</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">**** Input file name required</span>"
printHelp
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">exit</span> 1
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">endif</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">TMPNAME</span> = `<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">mktemp -dt pdfnup</span>`
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> $TMPNAME
<span class="comment" style="color: rgb(0, 0, 139); font-weight: bold; "># Default background color is white:
</span><span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">COLOR</span> = "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">FFFFFF</span>"
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">NUP</span> = "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">,</span>"
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">DELTA</span> = ""
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">OUTFILE</span> = ~/Desktop/converted.pdf
<span class="comment" style="color: rgb(0, 0, 139); font-weight: bold; "># Define the permissible command-line options:
</span><span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">ARGS</span> = `<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">getopt hd:n:c:o: $*</span>`
<span class="comment" style="color: rgb(0, 0, 139); font-weight: bold; "># Arguments preceding the special "--" are command-line options:
</span><span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">while</span> ("<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">$ARGS[1]</span>" != "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">--</span>")
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">switch</span> ("<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">$ARGS[1]</span>")
<span class="comment" style="color: rgb(0, 0, 139); font-weight: bold; "># Check if a color option is given:
</span> <span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">case</span> "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">-c</span>":
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">COLOR</span> = $ARGS[2]
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">shift</span> ARGS
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">breaksw</span>
<span class="comment" style="color: rgb(0, 0, 139); font-weight: bold; "># Output file name:
</span> <span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">case</span> "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">-o</span>":
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">OUTFILE</span> = "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">$ARGS[2]</span>"
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">shift</span> ARGS
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">breaksw</span>
<span class="comment" style="color: rgb(0, 0, 139); font-weight: bold; "># Check if an n-up option is given:
</span> <span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">case</span> "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">-n</span>":
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">NUP</span> = "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">,nup=</span>"$ARGS[2]
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">shift</span> ARGS
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">breaksw</span>
<span class="comment" style="color: rgb(0, 0, 139); font-weight: bold; "># Check if an offset option is given:
</span> <span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">case</span> "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">-d</span>":
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">DELTA</span> = "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">,delta=</span>"$ARGS[2]:s/x/ /
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">shift</span> ARGS
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">breaksw</span>
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">default</span>:
printHelp
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">exit</span> 0
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">breaksw</span>
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">endsw</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">shift</span> ARGS
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">end</span>
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">if</span> (-f $OUTFILE) <span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">then</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> -n "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">Output file </span>"$OUTFILE"<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; "> exists. Overwrite ? [yes/no]</span>"
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">overwrite</span> = "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">$<</span>"
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">if</span> ( $overwrite != "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">yes</span>" ) <span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">then</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">NOT OVERWRITING</span>"
cleanup
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">exit</span> 1
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">endif</span>
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">endif</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> '<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">\documentclass{minimal}\usepackage{xcolor}\pagecolor[HTML]{</span>'$COLOR'<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">}\usepackage{pdfpages}\begin{document}</span>' > $TMPNAME/converted.tex
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">shift</span> ARGS
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">set</span> <span class="variable-name" style="color: rgb(139, 0, 139); font-weight: bold; ">FILECOUNTER</span> = 0
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">foreach</span> i (`<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">echo "$ARGS"</span>`)
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">if</span> (-f $i) <span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">then</span>
@ FILECOUNTER++
cp "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">$i</span>" "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">$TMPNAME</span>"/$FILECOUNTER.pdf
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">else</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">**** Invalid filename </span>""<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">$i</span>"
printHelp
cleanup
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">exit</span> 1
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">endif</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> '<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">\includepdf[fitpaper,pages=-</span>'$NUP$DELTA'<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">,frame=false]{</span>'$FILECOUNTER.pdf'<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">}</span>' >> $TMPNAME/converted.tex
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">end</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> '<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">\end{document}</span>' >> $TMPNAME/converted.tex
pushd $TMPNAME
pdflatex -interaction nonstopmode converted.tex
<span class="comment" style="color: rgb(0, 0, 139); font-weight: bold; "># Return to original working directory:
</span>popd
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">if</span> ( -f $TMPNAME/converted.pdf) <span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">then</span>
mv $TMPNAME/converted.pdf $OUTFILE
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">Output written to </span>"$OUTFILE
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">else</span>
<span class="builtin" style="color: rgb(160, 32, 240); font-weight: bold; ">echo</span> "<span class="string" style="color: rgb(0, 139, 0); font-weight: bold; ">**** Couldn't convert</span>"
<span class="keyword" style="color: rgb(0, 0, 0); font-weight: bold; ">endif</span>
cleanup</pre><div><br></div></div><div><br></div><div><br></div></body></html>