3

I have a pdf and need to have each second page turned upside down, so that I can print it twosided. I found pdfpages rotate odd pages 180º and changing

 \foreach \p in {1,...,\the\pdflastximagepages}{%
  \ifnumodd{\p}%
    {\includepdf[pages=\p,angle=180]{\jobname-step1}}%
    {\includepdf[pages=\p]{\jobname-step1}}%
}

to

 \foreach \p in {1,...,\the\pdflastximagepages}{%
  \ifnumodd{\p}%
    {\includepdf[pages=\p,angle=180]{\jobname-step1}}%
    {\includepdf[pages=\p+1]{\jobname-step1}}%
}

(amongst other changes) would do the job I think. But adding the \p+1 gives an error. I tried it with the package calc, but without any luck.

3

2 Answers 2

2

After some long hours I got the following to do the job:

\documentclass[landscape]{article}
\usepackage{pgffor,pgfmath,pdfpages}

\def\originalfile{backlog-grooming.pdf}

\begin{document}

\pdfximage{\originalfile}%
\foreach \p in {1,3,...,\the\pdflastximagepages}{%
   \pgfmathparse{int(\p+1)}%
   {\includepdf[pages=\p]{\originalfile}}%
   {\includepdf[pages=\pgfmathresult,angle=180]{\originalfile}}%
}


\end{document}

In the file backlog-grooming.pdf every second page is turned upside down.

1

Try

\foreach \p in {1,...,\the\pdflastximagepages}{%
  \ifnumodd{\p}%
    {\includepdf[pages=\p]{\jobname-step1}}%
    {\includepdf[pages=\p,angle=180]{\jobname-step1}}%
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .