Merge two PDF files output by LaTeX?

I would like to (re)submit a paper with a short cover letter, explaining the changes I have made. However, the journal only allows me to upload one file. As the main article will use the journal style class, and so forth, it's not really practical to use the 1st page for the letter (or is it? Could I reset the page number etc. etc.??)

Instead, could I create, say, two PDF files (one the letter, the other the article) and then somehow merge them together?

-
Hi Matthew, welcome to tex.SX! If you tell us what operating system you're using then that would help as the ways to do this vary from OS to OS. –  Loop Space Jan 10 '11 at 21:45
Well, I have a very up-to-date version of MikTex on Windows, and also a rather old Linux system at work... –  Matthew Daws Jan 10 '11 at 22:15
Would zipping the two files together into one archive suffice, or has your one uploaded file got to be a pdf? –  Edd Jan 11 '11 at 21:46

Create the separate documents separately and merge them with a PDF utility. Semantically speaking, I feel this is the way to go rather than futzing with the document settings. After all, what you are submitting is not one "document" but a set of them.

Edit: This is an important question that has been asked more than once. It's also not exactly TeX-related. So I'm community-wikifying my answer so it can be improved and made definitive.

LaTeX

use Herbert's answer: the pdfpages package

\documentclass{article}% or something else
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-]{paper1}
\includepdf[pages=-]{paper2}

\end{document}


Command Line

• pdftk

$pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf  • $ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf source1.pdf source2.pdf source3.pdf etc.pdf


(via Macworld)

• PDFJAM is a suite of scripts that uses LaTeX and pdfpages on the backend.

\$ pdfjoin foo1.pdf foo2.pdf --outfile bar.pdf


(via Uwe Hermann)

• a few more options from an article at linux.com

GUI

This question is very similar although the questioner didn't realize it.

-
Beat me to it on pdftk; a very useful little program for mucking about with PDFs. –  Loop Space Jan 10 '11 at 21:45
I'll accept this; actually, I guess I should have search harder, as that other question was almost identical to mine! Many thanks to all. –  Matthew Daws Jan 10 '11 at 22:16
Am I the only one who has trouble with the output of pdftk working well with ghostcript? Ghostscript complains that pdftk output violates the PDF spec. I prefer the pdfjam scripts, which provide similar commandline functionality, but uses pdflatex/pdfpages for its backend. (For that matter, gs can itself combine PDFs from the commandline.) –  frabjous Jan 10 '11 at 22:25
@frabjous: I haven't had any problems with pdftk (which I've just been playing with); but also using gs directly works! –  Matthew Daws Jan 11 '11 at 9:06
Note that pdfpages removes all hyperlinks and other PDF annotations from the included PDFs. –  Martin Scharrer Jul 6 '11 at 19:37

Package pdfpagesmay help

\documentclass{article}% or something else
\usepackage{pdfpages}
\begin{document}
\includepdf{[pages=...]{paper1}
\includepdf{[pages=...]{paper2}

\end{document}

-
This works fine as well (once I noticed the typo: "includepdf" not "inlcudepdf"!) Actually, maybe this is the "nicest" way to do a cover letter, as then I can just include the PDF file of paper at the end. –  Matthew Daws Jan 11 '11 at 15:47
@Matthew: I had a knot in my fingers ... :-) –  Herbert Jan 11 '11 at 15:49

If you have Ghostscript installed, you might also join the two separate PDF files in one by issuing a command such as this:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf input1.pdf input2.pdf

-