[Tex/LaTex] Simple frame around page

framedmargins

I need add a frame around all page in latex. If I search on google, I find many options, but anything work well for me. Also I need that page would be A4 and have margin 1.27cm. And on the top of first page I need a head:
enter image description here

EDIT (my code and preview):

    \documentclass[10pt,a4paper]{article}

\usepackage[cp1250]{inputenc}
\usepackage[czech]{babel}

\usepackage[total={18.46cm,27.16cm}, top=1.27cm, left=1.27cm, noheadfoot, nomarginpar,showframe]{geometry}

\pagenumbering{gobble}

\begin{document}
\begin{table}[t]
    \begin{tabular}{ll|ll|ll}
    Jmeno: & ~ & Třída & ~ & LP č. & ~ \\ \hline
    Téma   & ~ & ~     & ~ & ~     & ~ \\
    \end{tabular}
\end{table}
 \end{document} 

enter image description here

Best Answer

Using tikzpagenodes and eso-picthis can be done as below. Please note that instead of eso-pic, one can also use background package.

\documentclass[a4paper]{article}
\usepackage{lipsum}
\usepackage[a4paper,margin=2cm,headheight=2cm,headsep=4ex]{geometry}
\usepackage{tikzpagenodes}
\usepackage{eso-pic}
\AddToShipoutPictureBG{%
 \begin{tikzpicture}[remember picture,overlay]
   \node[inner sep=0pt,text width=\linewidth+2ex+\pgflinewidth,anchor=center] (H) at (current page header area.south) {%
   \begin{tabular*}{\linewidth}{|p{\dimexpr0.4\linewidth-8\tabcolsep\relax}
                                |p{0.2\linewidth}
                                |p{0.2\linewidth}
                                |p{0.2\linewidth}|}% \hline
   Umeno: & Trida: & Datum: & Lpc: \\\hline
   \multicolumn{4}{|l|}{Tema} \\\hline
   \end{tabular*}%
   };
   \draw ([shift={(-1ex,-1ex)}]current page text area.south west) rectangle
          (H.north east);
 \end{tikzpicture}
}


\begin{document}
\lipsum[1-150]
\end{document}

enter image description here

If you want the table for only first page, define a page style using fancyhdr and use it only for first page.

\documentclass[a4paper]{article}
\usepackage{lipsum}
\usepackage[a4paper,margin=2cm,headheight=3cm,headsep=2ex]{geometry}
\usepackage{tikzpagenodes}
\usepackage{eso-pic}
\AddToShipoutPictureBG{%
 \begin{tikzpicture}[remember picture,overlay]
   \draw ([shift={(-1ex,-1ex)}]current page text area.south west) rectangle
          ([shift={(1ex,0ex)}]current page header area.south east);
 \end{tikzpicture}
}

\usepackage{fancyhdr}
\fancypagestyle{firstpage}{%
\fancyhf{}
\fancyhead[C]{%
\makebox[\textwidth][c]{%
\begin{tabular*}{\dimexpr\linewidth+2ex\relax}{|p{\dimexpr0.4\linewidth-8\tabcolsep+2ex\relax}
                                |p{0.2\linewidth}
                                |p{0.2\linewidth}
                                |p{0.2\linewidth}|}\hline
   Umeno: & Trida: & Datum: & Lpc: \\[1ex]\hline
   \multicolumn{4}{|l|}{Tema} \\[1ex]
   \end{tabular*}%
   }}
 \fancyfoot[C]{\thepage}
 \renewcommand{\headrulewidth}{0pt}
   }


\begin{document}
\thispagestyle{firstpage}
\lipsum[1-150]
\end{document}

enter image description here