# The frame of a \framebox disappears in pdfpages

I am trying to put the word "hello" on every page of a pdf file using pdfpages. The following code works, but the frame around "hello" disappears. I tried it on a one blank page pdf file (called "letter.pdf" in the same directory). The first page has an unboxed "hello", but the next page (output in an ordinary way, without the pdfpages callback) works just fine.

\documentclass{minimal}
\usepackage[final]{pdfpages}
\begin{document}
% page 1 (no frame around hello)
\newcommand{\eachpage}{\framebox[1in][l]{hello}}
\includepdf[pages=-,pagecommand={\eachpage}]{letter.pdf}
% page 2 (frame works)
\framebox[1in][l]{hello}
\end{document}


The package pdfpages always draws a frame around the included page; but the default is not showing it, which is obtained by setting \fboxrule to zero. Since the addition of pagecommands happens during PDF inclusion, a \framebox will inherit this setting. Note that pdfpages also sets \fboxsep to zero.

Solution:

\newlength{\defaultfboxrule}
\newlength{\defaultfboxsep}
\AtBeginDocument{% Remember the values
\setlength{\defaultfboxrule}{\fboxrule}%
\setlength{\defaultfboxsep}{\fboxsep}%
}
\newcommand{\normalfboxes}{%
\setlength{\fboxrule}{\defaultfboxrule}%
\setlength{\fboxsep}{\defaultfboxsep}%
}

\newcommand{\eachpage}{%
\begingroup\normalfboxes
\framebox[1in][l]{hello}%
\endgroup
}