[Tex/LaTex] Margins around Tikz frame

marginsmdframedtikz-styles

I'm dealing with the graphic part of a document which I need to fill with text.
In particular I need to have a header where to put some general information and the document text simply boxed.

Depending on the text verbosity, the document can be one page or x pages. In this last case, starting from page 2, I don't want anymore the header, but only the text boxed.

I tried to figure how to obtain the boxed text and I discovered Tikz. But I have some problems by defining the margins of the box and then the text behavior for the page after the first. The top margin seems to disappear, I don't understand why. I tried a lot of solutions, using \fbox or using \trimbox{} and \adjustebox, but I didn't find a solution yet.

Secondly, I can't make the header disappear after the first page. I tried with \clearpage and \thispagestyle{empty} but they remove margins and page numbering also.

I a MWE to show what I did until now:

\documentclass[a4paper]{article}
\usepackage[all]{background}

\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage[sfdefault, light]{roboto}
\usepackage{adjustbox}

\usepackage{geometry} 
\geometry{left=80pt, right=80pt, top=65pt}
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}

\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{\footnotesize Page \thepage\ of \pageref{LastPage}}
\chead{{\large \textsc{My Name IS}}\\ \vspace{3pt} {\small My Work IS -- My Specialisation IS}\\ My Cell. IS -- My ID IS}
\renewcommand{\headrulewidth}{0pt}

\usepackage{lettrine}
\usepackage{fix-cm}

\newcommand{\Frame}{
\trimbox{10cm 10cm 10cm 5cm}{
\begin{tikzpicture}[every node/.style={inner sep=10,outer sep=10},overlay, remember picture]
\draw [line width=1mm]
    ($ (current page.north west) + (1cm,-3cm) $)
    rectangle
    ($ (current page.south east) + (-1cm,1cm) $);
\end{tikzpicture}
}
}

\SetBgContents{\Frame}
\SetBgOpacity{100}
\SetBgColor{black}
\SetBgAngle{0}
\SetBgScale{1}

\begin{document}
\vspace*{50pt}

 \lipsum[1-19]  

\end{document}

Thank you for your time and help!
R.

Best Answer

I prefer to use everypage with tikzpagenodes for headers etc.

\documentclass[a4paper]{article}
\usepackage[all]{background}

\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{lipsum}
%\usepackage[sfdefault, light]{roboto}

\usepackage{geometry} 
\geometry{left=80pt, right=80pt, top=65pt}
%\usepackage[T1]{fontenc} 
%\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\usepackage{lettrine}
\usepackage{fix-cm}

\pagestyle{empty}

\usepackage{everypage}
\AddEverypageHook{\ifnum\value{page}=1
\begin{tikzpicture}[every node/.style={inner sep=0pt},overlay, remember picture]
  \node[above] at (current page footer area.south) {\footnotesize Page \thepage\ of \pageref{LastPage}};
  \node[below] at (current page header area.north)
  {\begin{tabular}{c}
    {\large \textsc{My Name IS}}\\[3pt]
    {\small My Work IS -- My Specialisation IS}\\
    My Cell. IS -- My ID IS
  \end{tabular}};
  \end{tikzpicture}%
\else
  \begin{tikzpicture}[overlay, remember picture]
  \node[above] at (current page footer area.south) {\footnotesize Page \thepage\ of \pageref{LastPage}};
  \draw [line width=1mm]
    ($ (current page.north west) + (1cm,-1cm) $)
    rectangle
    ($ (current page.south east) + (-1cm,1cm) $);
  \end{tikzpicture}%
\fi}

\begin{document}
\vspace*{50pt}

 \lipsum[1-19]  

\end{document}