# Break PDF booklet into pages

I have a PDF with booklet-odered pages (like the one below). I would like to break these PDF A4 pages back into the original twice as many PDF A5 pages.

|-------| PDF page 1
| 8   1 |
|-------|

|-------| PDF page 2
| 2   7 |
|-------|

|-------| PDF page 3
| 6   3 |
|-------|

|-------| PDF page 4
| 4   5 |
|-------|

-
May be this thread in comp.text.tex could help you: Splitting 2 pages/page landscape postscript file into two single page portrait pages –  Ignasi Jul 10 '12 at 13:57

Here's a solution via tikz and graphicx. Two compilations are required. gen.pdf is your booklet PDF file.

\documentclass[a5paper]{article}
\usepackage{geometry}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\foreach \page in {1,...,4}{
\begin{tikzpicture}[overlay,remember picture]
\ifodd\page
\node at (current page)
{\includegraphics[page=\page,trim=148.5mm 0 0 0]{gen.pdf}};
\else
\node at (current page)
{\includegraphics[page=\page,trim=0 0 148.5mm 0]{gen.pdf}};
\fi
\end{tikzpicture}
\newpage
}
\foreach \page in {4,...,1}{
\begin{tikzpicture}[overlay,remember picture]
\ifodd\page
\node at (current page)
{\includegraphics[page=\page,trim= 0 0 148.5mm 0]{gen.pdf}};
\else
\node at (current page)
{\includegraphics[page=\page,trim= 148.5mm 0 0 0]{gen.pdf}};
\fi
\end{tikzpicture}
\newpage
}
\end{document}

-
Thanks, after some tweaking it works for me. For the tweaks, see my CW answer. –  yo' Jul 10 '12 at 20:56

Modification of the solution by PolGab, I got away the tikzpicture part which is completely unnecessary IMO, and I use tikz only for \foreach.

\documentclass[a5paper]{article}
\usepackage[margin=0pt]{geometry}
\usepackage{tikz}
\pagestyle{empty}
\def\placepage#1{%
\leavevmode\kern-0.25in{#1}%
}
\begin{document}
\foreach \page in {1,...,4}{
\ifodd\page
\placepage{\includegraphics[page=\page,trim=148.5mm 0 0 0]{y.pdf}}
\else
\placepage{\includegraphics[page=\page,trim=0 0 148.5mm 0]{y.pdf}}
\fi
\newpage
}
\foreach \page in {4,...,1}{
\ifodd\page
\placepage{\includegraphics[page=\page,trim= 0 0 148.5mm 0]{y.pdf}}
\else
\placepage{\includegraphics[page=\page,trim= 148.5mm 0 0 0]{y.pdf}}
\fi
\newpage
}
\end{document}

-
tikz is certainly not necessary... but it is convenient to properly position the elements. Are you sure that your A5 page contents are perfectly centered (vertically and horizontally) ? Why -0.25in ? –  Paul Gaborit Jul 11 '12 at 5:51
Instead of \usepackage{tikz} you could only use \usepackage{pgffor} which provides \foreach command without other TiKZ tools and commands. pgffor package is part of TiKZ. –  Ignasi Jul 11 '12 at 8:14
@PolGab sorry to say that, but your code gave me completely wrong placement. –  yo' Jul 11 '12 at 21:59
@tohecz A wrong placement is the result of the first compilation. With a second compilation, placement should be perfect. –  Paul Gaborit Jul 11 '12 at 22:22

... and here are detailed descriptions how you can do that with the help of Ghostscript:

-