Using \put command relative to page size

I want to include a logo in the pdf pages included in Beamer.

I tried writing macro and progressed so far.

\documentclass[fleqn,xcolor=dvipsnames]{beamer}

\newlength{\logosize}
\setlength{\logosize}{7.50mm}

\newlength{\logoXinpdf}
\newlength{\logoYinpdf}
\setlength{\logoXinpdf}{0.9\textwidth}
\setlength{\logoYinpdf}{0.8\textheight}

\usepackage{pdfpages}

\def\getpdfpages#1#2{\begingroup
\setbeamercolor{background canvas}{bg=}
\includepdf[pages={#1},picturecommand={\put(\logoXinpdf,\logoYinpdf){\pgfimage[width=\logosize]{mylogo}}}]{#2}
\endgroup}

\begin{document}

\getpdfpages{{9,12}}{mypdf.pdf}

\end{document}


However, when I run pdfLaTeX, I get an error in the line of,

! A <box> was supposed to be here.
\unitlength
l.23 \getpdfpages{{9,12}}{mypdf.pdf}


I understand that the problem is with the \put command. If I replace the \logoXinpdf,\logoYinpdf lengths with absolute numbers, everything works fine.

Is there a way I can use these defined lengths with the \put command?

-
Your mistake here is that arguments of \put are in \unitlength units, not an usual length. Try to include fp package and compute coordinates by dividing your lengths by value of \unitlength. –  Eddy_Em Feb 3 '13 at 7:50
Thanks, @Eddy_Em. Modifying the code in the following manner solved my problem, \makeatletter \FPdiv{\logoX}{\strip@pt\logoXinpdf}{\strip@pt\unitlength} \FPdiv{\logoY}{\strip@pt\logoYinpdf}{\strip@pt \unitlength} \makeatother \def\getpdfpages#1#2{\begingroup \setbeamercolor{background canvas}{bg=} \includepdf[pages={#1},picturecommand={\put(\logoX,\logoY){\pgfimage[width=\logo‌​size]{buetlogo}}}]{#2} \endgroup} –  Masroor Feb 3 '13 at 8:36
@MMA: If this solved your problem please post it as an self-answer (after the waiting period) and accept it in order to conclude the question. –  Martin Scharrer Feb 3 '13 at 10:07

It's actually sufficient just to locally disable \unitlength (assuming this is a picture mode command internally.

\def\getpdfpages#1#2{\begingroup
\setbeamercolor{background canvas}{bg=}
\includepdf[pages={#1},picturecommand={{\def\unitlength{}\put(\logoXinpdf,\logoYinpdf){\pgfimage[width=\logosize]{mylogo}}}}]{#2}
\endgroup}


\put expects a multiplier and does essentially

\setlength\something{#1\unitlength}
\setlength\somethingelse{#2\unitlength}


So if \unitlength is empty it is OK to pass lengths to put. Heiko's picture package takes this a bit further and adds some conditional logic so that you can use either a length or a multiplier, so that \unitlength becomes essentially a default unit. So it is probably enough just to load picture and make no change to your code.

-