%%% -*-LaTeX-*-
%%% ====================================================================
%%% The code in this file was inspired by postings on 26-Feb-2019 on
%%% the texhax mailing list.  It converts a 2-up book scan to 1-up
%%% pages for reading and printing convenience.
%%%
%%% That new file in PDF-1.5 format is then processed here to extract
%%% rectangles of text from the left and right side of a landscape
%%% format page, and output each pair on two separate pages.  The
%%% viewports, horizontal space, and clip options have been manually
%%% tweaked to produce decent centering of the text on each page for
%%% possible printing.  The papersize in the second LaTeX line is set
%%% to match the rotated original page size (recall that PostScript
%%% uses big points (bp)).
%%%
%%% [27-Feb-2019]
%%% ====================================================================

\documentclass{minimal}

% pdfinfo RC_4000_Reference_Manual_Jun69-ocr.pdf
%     Page size:      423.84 x 613.92 pts (rotated 0 degrees)
%     File size:      4981965 bytes
% Adobe Acrobat: Page size: 11.68 x 8.26in [840.96bp x 594.72bp] 

\newcommand {\twoupfile} {RC_4000_Reference_Manual_Jun69-ocr.pdf}

\usepackage[papersize={423bp,614bp}, margin=0pt, ignoreall]{geometry}
\usepackage{graphicx}

\setlength{\parindent}{0pt}

\begin{document}

\pdfximage page 1 {\twoupfile}  % get page count from 2-up PDF file

\count253 = \pdflastximagepages

\count254 = 1

\loop
     \ifnum \count254 = 1
       \hspace*{2mm}\includegraphics[viewport =   0   0 411 614, clip = true, page = \count254]{\twoupfile}\newpage
       % skip blank page to get input odd page numbers on output odd sequential page
     \else
       \hspace*{0mm}\includegraphics[viewport =   0   0 421 595, clip = false, page = \count254]{\twoupfile}\newpage
       \hspace*{0mm}\includegraphics[viewport = 421   0 424 595, clip = false, page = \count254]{\twoupfile}\newpage
     \fi
\ifnum \count254 < \count253 %%% maximum page number
     \advance \count254 by 1
\repeat

\end{document}
