[Tex/LaTex] Vertical line and text

linemarginnotemarginparmarginsvertical

I am trying to insert a vertical line and some text or image in the margin as in the picture no matter if it is an image or a text with several lines enter image description here

However the source code embeds the line and text in all pages and the text after the \begin{document} is too narrow.

Thanks for the support

\documentclass[10pt,a4paper]{article}
\usepackage[all]{background}
\usepackage{lipsum}

\SetBgContents{Text here but with several lines}% Set contents
\SetBgPosition{-0.0cm,1.5cm}% Select location
\SetBgOpacity{1.0}% Select opacity
\SetBgAngle{0.0}% Select rotation of logo
\SetBgScale{1.0}% Select scale factor of logo

\newlength{\leftrule}
\newlength{\rightrule}
\setlength{\leftrule}{2\leftmargin-\marginparsep}
\setlength{\rightrule}{2\leftmargin+\textwidth+\marginparsep}
 \AddToShipoutPicture{%
\AtPageLowerLeft{%
\put(\LenToUnit{\leftrule},0){\rule{0.3pt}{\paperheight}}  % Rule on the left
%\put(\LenToUnit{\rightrule},0){\rule{1pt}{\paperheight}}  % Rule on the right
}
}

\begin{document}
\lipsum
\end{document}

Best Answer

I'd use the fancyhdr package for that. See the example. It surely contains many hardcoded constants, so it could be done better.

\documentclass[10pt,a4paper,draft]{article}
\usepackage[all]{background}
\usepackage{lipsum}
\usepackage{tikz}

\def\pictureOne{\begin{tikzpicture}\draw[red] (0,0)--(0,2)--(2,2)--(2,0)--cycle;\end{tikzpicture}}
\def\pictureTwo{\begin{tikzpicture}\draw[blue] (0,0)--(0,2)--(2,2)--(2,0)--cycle;\end{tikzpicture}}

\usepackage{fancyhdr}
\pagestyle{fancy}

\def\headrulewidth{0pt}
\newlength{\ruleheight}
\setlength{\ruleheight}{\textheight}
\addtolength{\ruleheight}{20mm}
\fancyhead{}
\fancyhead[L]{%
    \vbox to 0pt{%
    \vskip 5mm \hbox{%
        \hskip-5mm\vrule height\ruleheight%
        \hskip-25mm\vbox to \ruleheight{\pictureOne\vss\pictureTwo}}%
        \vss}}
\fancyfoot{}
\fancyfoot[C]{\footnotesize\thepage}

\begin{document}
\lipsum
\end{document}