1

I have a single PDF document that I want to include into my script. It is supposed to be used as a double page, like you open the book and the left page is the left half of the PDF document and right is right.

Is this possible or should I try to separate the PDF into two parts and just use \includepdf ? I read the pdfpages docs and used several options, yet without success.

Edit: The PDF I want to include only has 1 page but is supposed to be two pages in the final document.This is the PDF

3
  • a range of pages of course, yes, but I want to extend a single page PDF document over 2 pages.
    – Donvini
    May 12, 2018 at 12:08
  • The paper size is not the problem, its 2 A4 pages wide, but when I include it, it gets turned 90 degrees instead of spreading over 2 pages. I set landscape to false and it didn't change.
    – Donvini
    May 12, 2018 at 12:12
  • sorry I misread the question (I deleted the first comment:-) May 12, 2018 at 12:51

2 Answers 2

6

There is a bit of confusion over dimensions when scaling and clipping at the same time, so I did it in two stages. I scaled using \includegraphics into a savebox, then clipped the savebox using \adjustbox.

The file is what I got when I copied the above image.

\documentclass{article}
\usepackage{graphicx,adjustbox}
\begin{document}
\sbox0{\includegraphics[height=\textheight]{images/ON4re}}% scale impage
\noindent\adjustbox{clip, viewport=0pt 0pt 0.5\wd0 \ht0}{\usebox0}

\noindent\adjustbox{clip, viewport=0.5\wd0 0pt \wd0 \ht0}{\usebox0}
\end{document}

demo

1
  • Great, I wouldn't have come up with this solution on my own, thank you a lot! it's really elegant.
    – Donvini
    May 12, 2018 at 13:56
4

Here is a way to put the picture in the background, covering the whole page.

\BackgroundHalfPicture takes l or r as first parameter to select the left or right half, and the second is the picture.

The line \mbox{} is necessary, because \newpage doesn't generate empty pages. You could instead write something on the page, you just need to move it to the door.

The result:

enter image description here

The code:

\documentclass[a4paper]{article}
\usepackage{graphicx,adjustbox}
\usepackage{eso-pic}

\makeatletter
\newcommand{\BackgroundHalfPicture}[2]{%
    \sbox0{\includegraphics[height=\paperheight]{#2}}%
    \AddToShipoutPictureBG*{%
        \AtPageLowerLeft{\makebox(\LenToUnit{\paperwidth},\LenToUnit{\paperheight}){%
            \def\@tempa{#1}\def\@tempb{l}%
            \ifx\@tempa\@tempb
                \adjustbox{clip, viewport=0pt 0pt 0.5\wd0 \ht0}{\usebox0}%
            \else
                \adjustbox{clip, viewport=0.5\wd0 0pt \wd0 \ht0}{\usebox0}%
            \fi
        }}%
    }%
}
\makeatother


\begin{document}
\thispagestyle{empty}
\BackgroundHalfPicture{l}{ON4re}
\mbox{}

\newpage
\thispagestyle{empty}
\BackgroundHalfPicture{r}{ON4re}
\mbox{}
\end{document}

You must log in to answer this question.

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