This method will work with fully text documents only, but will break down for documents that include images and/or \colorbox
es.
The macro \blurpages{start page}{end page}{PDF file}
takes a complete unblurred document as its 3rd argument.
It builds successive blurry images for each page of the specified page range by stacking shifted images atop each other. It then outputs the blurred page and continues through the page range.
In this MWE, I operate on the file xcolor.pdf, the documentation for the xcolor
package.
\documentclass[a4paper]{article}
\usepackage{graphicx,ifthen,xcolor}
\usepackage[usestackEOL]{stackengine}
\usepackage{everypage}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
\AddThispageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
\raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{\textcolor{red}{#3}}}}}
\newcommand\ateveryxy[3]{%
\AddEverypageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
\raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{\textcolor{red}{#3}}}}}
% VERIFIED THAT SETTING \hoffset AND \voffset DO NOT BREAK SOLUTION.
%\hoffset=0.4in
%\voffset=0.2in
%WATERMARK ON EVERY PAGE
\ateveryxy{.5\paperwidth}{.55\paperheight}{\makebox[0pt]{\scalebox{15}{DEMO}}}
%CONSTRUCT BLURRED IMAGE
\setstackgap{L}{.4pt}
\newcommand\blur[2][1]{%
\Longstack{%
\,\includegraphics[page=#1,width=\paperwidth]{#2}\\
\,\,\,\includegraphics[page=#1,width=\paperwidth]{#2}\\
\includegraphics[page=#1,width=\paperwidth]{#2}\\
\,\,\includegraphics[page=#1,width=\paperwidth]{#2}\\
\,\,\,\,\includegraphics[page=#1,width=\paperwidth]{#2}
}%
}
%PLACE BLURRED IMAGES ON SUCCEEDING PAGES
\newcounter{blurpage}
\newcommand\blurpages[3]{%
\setcounter{blurpage}{#1}%
\whiledo{\value{blurpage}<#2}{%
\atxy{0in}{\paperheight}{\blur[\value{blurpage}]{#3}}\ \clearpage%
\stepcounter{blurpage}%
}%
\atxy{0in}{\paperheight}{\blur[\value{blurpage}]{#3}}\ \clearpage%
}
\pagestyle{empty}
\begin{document}
\blurpages{1}{9}{xcolor}
\end{document}
Here is where the method breaks down, however: if there are color filled regions, including both images and \colorboxes
.