The \@outputpage routine and the \@outputbox seem to be the right hooks in order to implement actions at start and end of the page body without affecting headers and footers.
As an example we overwrite \@outputpage to change the text colour in a cyclic way between red, green and blue for every new page by inserting two \pdfliteral around the original \@outputbox.
This was tested for a number of popular document classes and with a varying number of text columns.

\documentclass[a5paper,12pt]{memoir}
%\documentclass[twoside]{article}
%\documentclass{scrbook}
\pagestyle{myheadings}
\markboth{Left head}{Right head}
\usepackage{multicol}
\usepackage{lipsum}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% define actions for begin & end of page body
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{expl3}\ExplSyntaxOn
\seq_gset_from_clist:Nn\g_colour_stack_seq{1,0,0}
%cycle through red, green, blue text colours
\cs_new_nopar:Npn\doAtBegin{
\pdfliteral~direct~{q~\seq_use:Nn\g_colour_stack_seq{~}~rg}
\seq_gpop_right:NN\g_colour_stack_seq\l_tempa_tl
\seq_gput_left:NV\g_colour_stack_seq\l_tempa_tl
}
%reset to graphics state before colour change
\cs_new_nopar:Npn\doAtEnd{\pdfliteral~direct~{Q}}
\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% overwrite output routine `\@outputpage'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\let\outputpageOrig\@outputpage
\def\@outputpage{
\setbox\@outputbox\vbox{%
\doAtBegin%
\box\@outputbox%
\doAtEnd%
}%
\outputpageOrig%
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\lipsum[1-3]
\begin{multicols}{3}
\lipsum[4-31]
\end{multicols}
\lipsum[32-35]
\end{document}
atbegshi, then it means that you're willing to try something that executes after the entire page has been constructed (headers/footers included). However, this contradicts what you mention at the start, where you want to insert content before headers/footers are inserted. Could you explain a little more? – Werner Nov 11 '15 at 14:18ocgenvironment in myocgx2package, in order to work across page breaks. Since theocgenvironment can be nested, I maintain a stack of open OCGs. At the end of the page, any open OCGs should be closed automatically (just calling\pdfliteral~direct~{EMC}per open OCG) to insert the required number ofEMCtags into the page content stream. Immediately at start of the next page, pending OCGs should be reopened by inserting the correspondingBDCtags. – AlexG Nov 11 '15 at 14:43everyshibecause, as you stated, headers/footers would become part of open OCGs which is, of course, not what I want. – AlexG Nov 11 '15 at 14:50{pdftex}-specific. – AlexG Nov 12 '15 at 07:47\specials or\pdfliterals, and the latter are implemented only in pdfTeX and LuaTeX, not XeTeX or TeX. – jarnosc Nov 12 '15 at 17:57