Is it possible to generate two PDF files from a single run?

The letter class makes it possible to generate two letters from a single run.

\documentclass[11pt]{letter}
\usepackage{lipsum}

\begin{document}
\name{John Doe}
\signature{John Doe}

\begin{letter}{Mr.\ Foo Bar}
\opening{Dear Mr.\ Bar}
\lipsum[1]
\end{letter}

\begin{letter}{Mr.\ Bar Foo}
\opening{Dear Mr.\ Foo}
\lipsum[2]
\end{letter}

\end{document}


But the resulting two letters are only logically distinct. They are generated in the same PDF file.

Is it ever possible, using any mechanism (irrelevant of letter), to get LaTeX to generate two ("physical", not logical) PDF files from a single run? Presumably the initialization in the preamble will be available for both.

My hunch is that this is not possible, and the best might be to concoct a shell script that passes a (boolean) parameter. Can you confirm?

• Why should you generate two PDF from the same LaTeX file in a single run? – Astrinus Dec 2 '16 at 16:40
• It depends what you define as a 'run'. If the compilation can spawn another compilation, it can compile a second PDF. This is how the externalisation of images works in PGF/TikZ, for example. But there is a separate compilation run for each PDF. Or you can use something like arara or rubber or mklatex to initiate multiple compilations. Or you can 'burst' a PDF after compilation using one of those tools to automate it. – cfr Dec 2 '16 at 16:48
• @Astrinus Why not? Otherwise, you have to split the PDF if you want to send the letters electronically, for example. – cfr Dec 2 '16 at 16:50
• – touhami Dec 2 '16 at 16:50
• @cfr you are talking about different letters, don't you? Why different documents should not go each in their own file?? – Astrinus Dec 2 '16 at 16:53