EDIT: My first answer was an emulation of \fancypage{\fcolorbox{red}{yellow}}{}
. See this solution below.
However, the question was about \fancypage{}{\fcolorbox{red}{yellow}}
. So first here comes my solution for that.
1. Solution for \fancypage{}{\fcolorbox{red}{yellow}}
Here is a lightweight solution (no additional packages needed):
\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}
%\fancypage{}{\fcolorbox{red}{yellow}}
\newcommand{\xcoord}{1in+\ifodd\value{page}\oddsidemargin\else\evensidemargin\fi-\fboxrule-\fboxsep}
\newcommand{\ycoord}{-1in-\voffset-\textheight-\topmargin-\headheight-\headsep-\footskip-\fboxsep}
\newlength\boxheight
\setlength\boxheight{\dimexpr\textheight+\footskip+\headheight+\headsep+\fboxsep}
\AddToHook{shipout/background}{%
\put(\xcoord,\ycoord){%
\fcolorbox{red}{yellow}{\vbox to \boxheight{\hspace{\textwidth}}}
}%
}%
\begin{document}
\lipsum[1-25]
\end{document}
If you have an older LaTeX that doesn't support the shipout/background
hook, this can be emulated with the everypage
package:
\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{everypage}
%\fancypage{}{\fcolorbox{red}{yellow}}
\newcommand{\xcoord}{\ifodd\value{page}\oddsidemargin\else\evensidemargin\fi-\fboxrule-\fboxsep}
\newcommand{\ycoord}{-\voffset-\textheight-\topmargin-\headheight-\headsep-\footskip-\fboxsep}
\newlength\boxheight
\setlength\boxheight{\dimexpr\textheight+\footskip+\headheight+\headsep+\fboxsep}
\AddEverypageHook{%
\put(\xcoord,\ycoord){%
\fcolorbox{red}{yellow}{\vbox to \boxheight{\hspace{\textwidth}}}
}%
}%
\begin{document}
\lipsum[1-25]
\end{document}
2. Solution for \fancypage{\fcolorbox{red}{yellow}}{}
Here is a lightweight solution (no additional packages needed):
\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}
%\fancypage{\fcolorbox{red}{yellow}}{}
\newcommand{\xcoord}{1in+\ifodd\value{page}\oddsidemargin\else\evensidemargin\fi-\fboxrule-\fboxsep}
\newcommand{\ycoord}{-1in-\voffset-\textheight-\topmargin-\headheight-\headsep-\fboxsep}
\AddToHook{shipout/background}{%
\put(\xcoord,\ycoord){%
\fcolorbox{red}{yellow}{\vbox to \textheight{\hspace{\textwidth}}}
}%
}%
\begin{document}
\lipsum[1-25]
\end{document}
If you have an older LaTeX that doesn't support the shipout/background
hook, this can be emulated with the everypage
package:
\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{everypage}
%\fancypage{\fcolorbox{red}{yellow}}{}
\newcommand{\xcoord}{\ifodd\value{page}\oddsidemargin\else\evensidemargin\fi-\fboxrule-\fboxsep}
\newcommand{\ycoord}{-\voffset-\textheight-\topmargin-\headheight-\headsep-\fboxsep}
\AddEverypageHook{%
\put(\xcoord,\ycoord){%
\fcolorbox{red}{yellow}{\vbox to \textheight{\hspace{\textwidth}}}
}%
}%
\begin{document}
\lipsum[1-25]
\end{document}
minimal
for examples.xcolor
orxcolor
's interaction withfancypage
, it seems.fancybox
replaces the output routine of LaTeX2e with a modified version of the old one in LaTeX 2.09. Avoid it.