%
% \CheckSum{49}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%% 
%% \iffalse meta-comment
%% ===================================================================
%%  @LaTeX-package-file{
%%    author         = {Rolf Niepraschk},
%%    version        = "0.5",
%%    date           = "11 July 1998",
%%    filename       = "eso-pic.sty",
%%    address        = "",
%%    telephone      = "",
%%    email          = "niepraschk@ptb.de",
%%    codetable      = "ISO/ASCII",
%%    keywords       = "LaTeX2e, \shipout, picture",
%%    dependences    = "everyshi",
%%    supported      = "yes",
%%    docstring      = "LaTeX package which makes it easy to add some  
%%                      picture commands to every page." 
%%  }
%% ===================================================================
%% \fi
%
%
% \ProvidesFile{eso-pic.dtx}
%    [1998/07/11 v0.5 eso-pic -- extension to `everyshi' (RN)]
%\iffalse   % this is a METACOMMENT !
%%
%% 
%% 
%
% \fi
%
% \GetFileInfo{eso-pic.dtx}
% \title{The \textsf{eso-pic} package\thanks{This file
%        has version number \fileversion, last
%        revised \filedate.}}
% \author{Rolf Niepraschk\addtocounter{footnote}{5}\thanks{
%   \texttt{niepraschk@ptb.de}}} 
%
% \date{}
%
% \maketitle
%
%  \begin{abstract}
%    This package makes it easy to add some picture commands to every page. 
%  \end{abstract}
%
% \section{Introduction}
%   This package is an extension to Martin Schr\"oder's \textsf{everyshi} package.
%   Using \textsf{every\-shi}'s \cs{EveryShipout} command \textsf{eso-pic} adds one or 
%   more userdefined \texttt{picture} commands to \LaTeX's shipout routine.
%
% \section{Usage}
%  \DescribeMacro{AddToShipoutPicture} All the picture commands which are
%  parameters of an \cs{AddToShipoutPicture} command will be added to the internal
%  macro \cs{\@ShipoutPicture@Hook}. This macro is part of a zero-length 
%  \texttt{picture} environment with basepoint at the lower left corner of the
%  page (similar to postscript). The \texttt{picture} 
%  environment will be shipped out at every new page. 
%  \DescribeMacro{ClearShipoutPicture} A call of \cs{ClearShipoutPicture} clears
%  the contents of \cs{\@ShipoutPicture@Hook}.   
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\begin{document}
   \DocInput{eso-pic.dtx}
\end{document}
%</driver>
% \fi 
%
% \section{Implementation}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1995/01/25] 
\ProvidesPackage{eso-pic}
   [1998/07/11 v0.5 eso-pic -- extension to `everyshi' (RN)]

\RequirePackage{everyshi}[1995/01/25]

\newcommand{\@ShipoutPicture@Hook}{}
\newcommand{\AddToShipoutPicture}{\g@addto@macro\@ShipoutPicture@Hook}
\newcommand{\ClearShipoutPicture}{\let\@ShipoutPicture@Hook\@empty}
\newcommand{\@ShipoutPicture}{%
  \ifx\@ShipoutPicture@Hook\@empty
  \else
    \bgroup
      \@tempdima=1in
      \@tempcnta=\@tempdima
      \@tempcntb=-\@tempdima
      \advance\@tempcntb\paperheight 
      \global\setbox\@cclv\vbox{%
      \vbox{%
        \unitlength=1sp%
        \begin{picture}(0,0)(\@tempcnta,\@tempcntb)% 
          \let\protect\relax\@ShipoutPicture@Hook%
        \end{picture}}%    
        \box\@cclv%
      }%   
    \egroup 
  \fi
}

\EveryShipout{\@ShipoutPicture}
%</package>
%    \end{macrocode}
%
% \section{Test file}
%
% \DescribeMacro{eso-p-t.tex} Produced framed pages.
%    \begin{macrocode}
%<*demo>
\documentclass[a4paper]{article}
\usepackage{eso-pic,calc}
\listfiles 

\makeatletter
  \AddToShipoutPicture{%
    \setlength{\@tempdima}{15mm}
    \setlength{\@tempdimb}{\paperwidth-2\@tempdima}
    \setlength{\@tempdimc}{\paperheight-2\@tempdima}
    \setlength{\unitlength}{1pt}\thicklines%
    \put(\strip@pt\@tempdima,\strip@pt\@tempdima){%
      \framebox(\strip@pt\@tempdimb,\strip@pt\@tempdimc){}
    } 
}     
\makeatother
    
\begin{document}
  
  \section*{First page}
  
  This page and all the following have a frame with 15~mm 
  distance from the paper edges.\newpage
  
  \section*{Second page} \newpage
  
  \section*{Last page}
\end{document}
%</demo>
%    \end{macrocode}
% \Finale
\endinput
