# Is there a package to divide pages of A4 to 2 pages of A5 each?

When I read a pdf book in my iPod touch using iBook software in landscape mode, I must zoom in each page manually. It means if I proceed to each page, I must zoom in until the left-right margins get aligned with the left-right margins of the display--- approximately 1/2 of a page will be displayed.

My idea is to divide each page in my book into 2 pages of A5. I hope I can do this for all pages automatically because doing it manually for more than 500 pages becomes tedious.

Is there a package to do that?

-
I am not sure I got this right, but maybe this question will be relevant: tex.stackexchange.com/questions/783/… –  Vivi Dec 15 '10 at 21:50
This problem is already solved. See my answer below. –  xport Dec 15 '10 at 21:58

I got the solution. I will use this pdf to be splitted. After downloading, I rename it as MVC.pdf.

Acrobat Reader informs me that the pdf has a width of 7.38 inches and a height of 9.25 inches.

I hope the magic numbers in the code snippet below are self-explanatory. If not, read pdfpages manual. :-)

\documentclass{article}
\usepackage{pdfpages}
\usepackage[paperwidth=6.38in,paperheight=4.025in,margin=0mm]{geometry}

\usepackage{multido}
\begin{document}
\multido{\i=50+1}{10}%
{%
\ifthenelse{\isodd{\i}}%
{%
\includepdf[pages=\i,trim=0.7in 4.325in 0.3in 0.9in,clip]{MVC}%
\pagebreak
\includepdf[pages=\i,trim=0.7in 0.4in  0.3in 4.825in,clip]{MVC}%
}%
{%
\includepdf[pages=\i,trim=0.3in 4.325in 0.7in 0.9in,clip]{MVC}%
\pagebreak
\includepdf[pages=\i,trim=0.3in 0.4in  0.7in 4.825in,clip]{MVC}%
}%
}%
\end{document}

-

This is very much not a pretty solution, but, given that you know the number of pages, you could use a combination of the forloop package and \includegraphics. As a small example:

\newcounter{pg}
\forloop{pg}{1}{\value{ct} < 5}% {%
\includegraphics[width=\textwidth,clip,viewport=0mm 0mm 210mm 148mm,page=pg]{thingy.pdf}
\pagebreak
\includegraphics[width=\textwidth,clip,viewport=0mm 148mm 210mm 207mm,page=\value{pg}]{thingy.pdf}
}


A better solution than the for loop would be to use the pdfpages package somehow, but I could not see how to do it.

-
Thank you for the solution. By the way, can we detect the book size on the fly instead of hard-coding the viewport? It is because my book size might not be exactly A4. –  xport Dec 15 '10 at 1:51
I assume the default/full page bounding box dimensions have to be stored by includegraphics somewhere. I can't read the package well enough to tell. There is a set of keys in graphicx called natwidth and natheight and another set bburx, bbury, bbllx, bblly, but I don't know which is right or how to access them. –  hoyland Dec 15 '10 at 2:09