# Modify single page size and insert image

I'm trying to generate a PDF where every page has a background image and some text placed at specific positions.

Some of the pages are normal A4 portrait and others are landscape.

My problem is that after I change a certain page size from portrait to landscape or the other way around, the coordinates for placing the image are messed up.

It seems like the \put coordinate y-axis is off by +/- 253.5mm after I change the page size.

\documentclass[10pt,a4paper]{article}
\pdfpagewidth 210mm
\pdfpageheight 297mm
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[a4paper,portrait,margin=0.0mm]{geometry}
\usepackage{eso-pic}
\usepackage[absolute,showboxes]{textpos}
\usepackage[pdftex]{graphicx}

\begin{document}
\fontfamily{phv} \selectfont
\thispagestyle{empty}

\begin{textblock*}{98.00mm}(24.00mm,38.00mm)
\raggedright
\normalsize
Some text\end{textblock*}

\put(0,0){%
\includegraphics[page=1,width=210mm,height=297mm]{backgroundimage.pdf}}}

\null\newpage

%change page to landscape
\eject \pdfpagewidth=297mm \pdfpageheight=210mm

\begin{textblock*}{98.00mm}(24.00mm,38.00mm)
\raggedright
\normalsize
Some text\end{textblock*}

% This image isn't placed correctly at 0,0 ...need to use \put(0,253.5)
\put(0,0){%
\includegraphics[page=1,width=297mm,height=210mm]{landscape.pdf}}}
\null\newpage

\end{document}

-
Have you tried the lscape or pdflscape packages? –  benwilfut Mar 18 '13 at 12:03
Actually I tried doing it with pdflscape at first, but it seemed to just rotate the page(text and image). Since I don't want the text and image to be rotated but only want to change the page size I looked for another solution. –  Demos Mar 18 '13 at 12:43

The package eso-pic uses the lengths \paperwidth and \paperheight to set the lower left anchor. In your MWE, you only change \pdfpagewidth and \pdfpageheight mid-document. If you also change \paperwidth and \paperheight, it works:

\documentclass[10pt,a4paper]{article}
\pdfpagewidth 210mm
\pdfpageheight 297mm
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[a4paper,portrait,margin=0.0mm]{geometry}
\usepackage{eso-pic}
\usepackage[absolute,showboxes]{textpos}
\usepackage[pdftex]{graphicx}

\begin{document}
\fontfamily{phv} \selectfont
\thispagestyle{empty}

\begin{textblock*}{98.00mm}(24.00mm,38.00mm)
\raggedright
\normalsize
\the\paperwidth hallo \the\paperheight\end{textblock*}

\put(0,0){%
\includegraphics[page=1,width=210mm,height=297mm]{backgroundimage.pdf}}}

\null\newpage

%change page to landscape
\eject \pdfpagewidth=297mm \pdfpageheight=210mm
\setlength{\paperheight}{210mm}
\setlength{\paperwidth}{297mm}

\begin{textblock*}{98.00mm}(24.00mm,38.00mm)
\raggedright
\normalsize
\the\paperwidth hallo \the\paperheight\end{textblock*}

% This image isn't placed correctly at 0,0 ...need to use \put(0,253.5)