Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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*}

\AddToShipoutPicture*{
\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)
\AddToShipoutPicture*{
\put(0,0){% 
\includegraphics[page=1,width=297mm,height=210mm]{landscape.pdf}}}
\null\newpage 

\end{document}
share|improve this question
    
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
add comment

1 Answer

up vote 1 down vote accepted

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*}

\AddToShipoutPicture*{
\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)
\AddToShipoutPicture*{
\put(0,0){% 
\includegraphics[page=1,width=297mm,height=210mm]{landscape.pdf}
}}
\null\newpage 

\end{document}
share|improve this answer
    
Thanks alot! - it's now working as expected. Saved me from writing some really messy code generating the document. –  Demos Mar 19 '13 at 6:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.