7

I have a book typeset with pages of 105mm x 180mm

This needs to made into a booklet, in signatures, such that it prints on A4 portrait paper, with the original book pages side by side. (i.e. 105mm + 105mm = 210mm, so it should fit)

If I use pdfpages (or the pdfbook shell script) I get them laid out side by side on landscape paper. If I tell it no-landscape, it puts them above one another, in such a way that rotating them with angle=90 doesn't help.

I need them laid out side by side on portrait paper because of paper-grain in the printing.

Diagram of the problem and desired solution

No combination of angle=90, landscape=true or false, or noautoscale with an explicit output papersize seems to work.

It seems like pdfpages, looks at the output paper size when signature is set, and decides to use either 2x1 or 1x2 for its nup, in such a way you can't override it.

So is this possible, without manually calculating the signature solution and just explicitly importing the content page by page?

NB: I don't care if the resulting PDF is portrait or landscape, because that is trivial to rotate when printing, I care about the relative orientation of the logical pages relative to the physical page.

Ian
  • 347
  • 1
  • 9
  • http://tex.stackexchange.com/questions/235515/pdfpages-pdfbook-for-odd-sizes-paper –  Mar 31 '15 at 04:59

4 Answers4

5

I'm using two or even more steps with the pdfpages package to get a printable PDF. Let me demonstrate it on a simple example.

  • First, let's prepare a 105x180 mm book with 16 pages, an original format. This is the input PDF file (*latex mal-a5.tex). Remove frame parameter in the real production.
  • Second, we convert the obtained PDF file to a new one, landscape orientation, A4, signature = number of pages in PDF (*latex mal-a5toa4.tex). This is a byproduct. In production, we could get number of pages in the PDF file automatically. You can find examples here at TeX.SX (see e.g. https://tex.stackexchange.com/a/180947/48028 and https://tex.stackexchange.com/a/179247/48028, I used \pdfximage and \pdflastximagepages in pdflatex+lualatex and \XeTeXpdfpagecount in xelatex).
  • Last, let's convert that new PDF file, simple rotation according to odd/even pages, portrait orientation, A4 (*latex mal-a4slides.tex). Let me hope it helps a bit. This should be the PDF file suitable for printing (portrait, two-side and long-edge printing).

I'm enclosing all three TeX files and a preview of the PDF files.

This is the mal-a5.tex file:

% *latex mal-a5.tex (twice)
\documentclass{article}
\paperwidth=105mm
\pdfpagewidth=\paperwidth
\paperheight=180mm
\pdfpageheight=\paperheight
\usepackage{tikz}

\begin{document}
\newcount\counter 
\counter=0
\loop
\advance\counter by 1
\newpage
\begin{tikzpicture}[remember picture, overlay]
\node[font=\bfseries\Huge\sffamily, scale=10] at (current page) {\the\counter};
\end{tikzpicture}
\ifnum\counter<16\repeat
\end{document}

input file: original book

This is a byproduct, the mal-a5toa4.tex file:

% *latex mal-a5toa4.tex
\documentclass[a4paper,landscape]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages={-},noautoscale,signature=16,frame]{mal-a5.pdf}
\end{document}

byproduct of the algorithm

This is the last file, the mal-a4sides.tex file.

% *latex mal-a4sides.tex
\documentclass[a4paper]{article}
\usepackage{pdfpages}
\begin{document}
\newcount\counter \counter=0
\loop
\advance\counter by 1
\ifodd\counter
  \includepdf[pages={\the\counter},noautoscale,angle=180]{mal-a5toa4.pdf}
\else
  \includepdf[pages={\the\counter},noautoscale]{mal-a5toa4.pdf}
\fi
\ifnum\counter<8\repeat
\end{document}

the final PDF ready to be printed

Malipivo
  • 13,287
  • I can't see the difference between the two last files – touhami Mar 28 '15 at 08:47
  • 1
    The paper is rotated (from landscape to portrait). If I didn't misread something in your question, this should be the wanted format. – Malipivo Mar 28 '15 at 08:51
  • thanks i am not de OP. My english is bad but i think he want 105+105=210 here you still have 105+105<290 – touhami Mar 28 '15 at 09:02
  • @touhami You are right, that's probably not the wanted output as my example fits the paper. I will wait for more details from the OP and rethink it. For now, I'm adding the noautoscale parameter to the middle TeX file. – Malipivo Mar 28 '15 at 09:08
  • I find that your solution may be good if you replace noautoscale by landscape and don't use it as class option – touhami Mar 28 '15 at 10:42
  • Thank you for the considerable detail, I appreciate it. It's not quite what I need, though. I've added a diagram to the question to clarify. Your solution still gives me the logical pages in the opposite orientation to the physical page. If the physical page is portrait, i need the logical pages to be side by side (and also portrait). Yours gives above each other and landscape. I seem to be able to generate most combinations except the one I want. – Ian Mar 28 '15 at 14:42
  • 2
    @Ian I gave it one more try. :-) – Malipivo Mar 28 '15 at 14:59
  • Thank you, that works. In my case my printer driver allows for duplexing by flipping on the short side, so the extra work for reversing alternate pages isn't needed. I'll add an answer with that, but I'll accept this one, as it is more general. Thanks. – Ian Mar 28 '15 at 15:18
4

You can do just the signatures reordering using pdfbook. Note that this program is different and independent from pdfbook from the pdfjam package (and I'm one of its authors, and current maintainer.)

After you've used pdfbook to reorder the pages, I think you should be able to use pdfpages with options nup=2x1,landscape=false to generate the final PDF.

Jaap Eldering
  • 1,760
  • 15
  • 20
  • My next step if there was no easy answer was to write a little script to do the signature-aware reordering, and then use nup as you say, so thank you, I think this looks like it will be the way forward, but I'll see if the other answer gets a one-shot result before accepting. – Ian Mar 28 '15 at 14:27
4

Malipivo's answer is a general one, using the pdfpages package.

You can also use the command line. Here's a solution

$ pdfbook --short-edge --noautoscale true document.pdf
$ pdfjam --noautoscale=true --no-landscape=true --suffix out document-book.pdf

The first command makes the booklet. The second then just imposes the booklet pages without scaling into the center of portrait pages.

Note on Short vs. Long Edge

The --short-edge parameter to the first command requires the easyshi package. If you don't have this, and omit it, then the temporary booklet is configured for long-edge duplex (which is probably what you'd want if you were printing it at that stage), but then the change to portrait makes that into short-edge duplex (you may have an option for this in your printer driver, or you can do it manually, so you can probably print it that way, even though it is less common). Setting it so that the initial booklet is made short-edge duplex, means the final output is long-edge, as you'd expect.

Ian
  • 347
  • 1
  • 9
1

As answered in a similar question, pdfpages looks at the output paper size to decide whether to use 2x1 or 1x2 for its nup, and it can be hacked to override the initial decision and always use a 2x1 nup. The following shell command using pdfjam does all the latex wrapping:

pdfjam --booklet true --paper a4paper --noautoscale true --preamble '\makeatletter\g@addto@macro\AM@prepare@signature{\def\AM@xnup{2}\def\AM@ynup{1}}' input.pdf

In the output above, however, every odd page is upside-down, which means you have to flip on short edge when duplex printing. If you also want long-edge duplexing, then the same hack can be added that is used under the hood by the --short-edge option of pdfbook to flip back every odd page.

pdfjam --booklet true --paper a4paper --noautoscale true --preamble '\usepackage{everyshi}\makeatletter\EveryShipout{\ifodd\c@page\pdfpageattr{/Rotate 180}\fi}\g@addto@macro\AM@prepare@signature{\def\AM@xnup{2}\def\AM@ynup{1}}' input.pdf

EDIT: The following picture shows the PDF page thumbnails of a sample input.pdf and the two booklets derived using the above commands as rendered by a PDF document viewer (thumbnails are not scaled proportionally).

PDF page thumbnails of a sample input.pdf and the two booklets derived from it

To generate the input.pdf, I used the following LaTex code.

\documentclass{article}
\usepackage[papersize={105mm,180mm}, margin=5pt]{geometry}
\usepackage{tikz,tikzpagenodes}
\pagestyle{empty}

\begin{document} \foreach \n in {1,...,16} { \newpage \begin{tikzpicture}[remember picture, overlay] \draw[blue, line width=10pt, fill=green!10] (current page text area.south west) rectangle (current page text area.north east); \node[font=\bfseries\Huge\sffamily, scale=10] at (current page) {\n}; \end{tikzpicture} } \end{document}