\setcounter{errorcontextlines}{100}
\listfiles
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{gefahrgutformular}
    [2020/07/09 v0.1c Gefahrgutformular (RN/PTB)]

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrartcl}}

\ProcessOptions\relax
\PassOptionsToPackage{paper=a4,pagesize}{typearea}

\LoadClass[%
,fontsize=10pt
]{scrartcl}

\setlength\textwidth{490bp}
\setlength\textheight{709bp}

\RequirePackage{iftex}

\ifluatex\else
  \ClassError{gefahrgutformular}{LuaTeX is required for this class. Aborting.}{%
    This class can only be used with the LuaTeX engine\MessageBreak
    (command `lualatex').}
  \expandafter\stop
\fi

\RequirePackage{fontspec}
%\setsansfont[Ligatures=TeX]{TeX Gyre Pagella}
\setmonofont{AnonymousPro-Regular}[%
  Extension = .ttf,
  BoldFont = AnonymousPro-Bold,
  ItalicFont = AnonymousPro-Italic,
  BoldItalicFont = AnonymousPro-BoldItalic,
  Scale     = 1.034
]
\setsansfont{texgyreheros}[
  Ligatures=TeX,
  Extension=.otf,
  UprightFont=*-regular,
  BoldFont=*-bold,
  ItalicFont=*-italic,
  BoldItalicFont=*-bolditalic.otf]

\RequirePackage{newunicodechar}
\newunicodechar{^^^^202f}{\,}% 'NARROW NO-BREAK SPACE' (\u202F, 8239)
\newunicodechar{^^^^2009}{\,\hspace{0pt}}% 'THIN SPACE'
\newunicodechar{^^^^00ad}{\-}% 'SOFT HYPHEN'

\renewcommand*\familydefault{\sfdefault}

\newcommand*\vl@doc@style@code{616~00~h}

\RequirePackage{graphicx,pict2e,picture,eso-pic}
\RequirePackage[ngerman]{babel}
\RequirePackage{siunitx-PTB}

\ifluatex\RequirePackage{luaimageembed}\fi
\iffalse % Warum geht das nicht?
\AtBeginDocument{%
  \ifx\vl@SignatureGraphic\@empty    
    \ifx\vl@SignatureGraphicBaseLXIV\@empty\else
       \usepackage{luaimageembed}%
    \fi
  \fi
}
\fi

\let\vl@tempdima=\@ovxx
\let\vl@tempdimb=\@ovyy
\let\vl@tempdimc=\@ovdx
\let\vl@tempdimd=\@clnwd
\let\vl@tempdime=\@clnht
\let\vl@tempdimf=\@dashdim

\newcommand*\vl@WorkingGroup{}
\newcommand*\WorkingGroup[1]{\gdef\vl@WorkingGroup{#1}}
\newcommand*\vl@Telephon{}
\newcommand*\Telephon[1]{\gdef\vl@Telephon{#1}}
\newcommand*\vl@Place{}
\newcommand*\Place[1]{\gdef\vl@Place{#1}}
\newcommand*\vl@Date{}
\newcommand*\Date[1]{\gdef\vl@Date{#1}}
\newcommand*\vl@Weight{}
\newcommand*\Weight[1]{\gdef\vl@Weight{#1}}
\newcommand*\vl@Package{}
\newcommand*\Package[1]{\gdef\vl@Package{#1}}
\newcommand*\vl@Type{}
\newcommand*\Type[1]{\gdef\vl@Type{#1}}
\newcommand*\vl@ContactPerson{}
\newcommand*\ContactPerson[1]{\gdef\vl@ContactPerson{#1}}
\newcommand*\vl@ContactPersonTelephon{}
\newcommand*\ContactPersonTelephon[1]{\gdef\vl@ContactPersonTelephon{#1}}
\newcommand*\vl@SignatureGraphic{}
\newcommand*\SignatureGraphic[1]{\gdef\vl@SignatureGraphic{#1}}
\newcommand*\vl@SignatureGraphicBaseLXIV{}
\newcommand\SignatureGraphicBaseLXIV[1]{%
  \long\gdef\vl@SignatureGraphicBaseLXIV{#1}}
\newcommand*\vl@SenderAddress{}
\newcommand*\SenderAddress[1]{\long\gdef\vl@SenderAddress{#1}}
\newcommand*\vl@RecipientAddress{}
\newcommand*\RecipientAddress[1]{\long\gdef\vl@RecipientAddress{#1}}
\newcommand*\vl@Comment{}
\newcommand*\Comment[1]{\gdef\vl@Comment{#1}}
\newcommand*\vl@Items{}
\newcommand\Items[1]{\long\gdef\vl@Items{#1}}

\AddToShipoutPictureBG{%
  \frenchspacing
  \AtPageLowerLeft{%
    \linethickness{0.6bp}%
    \vl@tempdima=54bp %
    %------ Rahmen ------
    \put(\vl@tempdima,68bp){\framebox(\textwidth,\textheight){}}%
    %------ alle waagerechten Linien und Texte in der Nähe ------
    \vl@tempdimb=694bp %
    \put(\vl@tempdima,\vl@tempdimb){
      \put(4bp,65bp){\resizebox{202bp}{!}{\textbf{\Large Beförderung von 
        Gefahrgütern}}}%
      \put(4bp,35bp){\resizebox{106bp}{!}{\Large In Braunschweig an:}}%
      \put(4bp,7bp){\resizebox{31bp}{!}{\textbf{\Large Q.212}}}%
      \vl@tempdimc=-17bp %
      \put(4bp,\vl@tempdimc){Organisationseinheit:}% 
        \put(4bp,2.5\vl@tempdimc){\vl@WorkingGroup}% 
      \put(171bp,\vl@tempdimc){Hausruf:}%   
         \put(171bp,2.5\vl@tempdimc){\vl@Telephon}% 
      \put(332bp,\vl@tempdimc){Ort, Datum:}%
         \put(332bp,2.5\vl@tempdimc){\vl@Place, \vl@Date}%
      \line(1,0){\textwidth}%
    }%
    \vl@tempdimb=644bp %
    \put(\vl@tempdima,\vl@tempdimb){%
      \vl@tempdimc=-17bp %
      \put(4bp,\vl@tempdimc){%
         \parbox[t]{334bp}{%
            \textbf{Gefahrgut} {\scriptsize (Bei Luft-/See- oder 
            Schienentransport Sicherheitsdatenblätter zwingend mitschicken)} 
            Bei Gemischen Angabe der 2 Hauptkomponenten in~\%, bei Säuren und 
            Laugen Konzentrationsangaben in~\%
            \ifx\vl@Items\@empty\else
              \noindent\hskip-30pt %
              \begin{itemize}%
                \scriptsize
                \vl@Items
              \end{itemize}%
            \fi
         }%
      }%
      \put(347bp,\vl@tempdimc){%
         \parbox[t]{137bp}{%
            \textbf{Netto-Gewicht} in kg (bei mehr als einem Gut 
            Einzelgewichte):\par\medskip\vl@Weight
         }%
      }% 
      \line(1,0){\textwidth}%
    }%
    \vl@tempdimb=406bp %
    \put(\vl@tempdima,\vl@tempdimb){%
      \vl@tempdimc=-17bp %
      \put(4bp,\vl@tempdimc){\textbf{Ansprechpartner} (für Rückfragen)}%
        \put(4bp,2.1\vl@tempdimc){\vl@ContactPerson}%     
      \put(347bp,\vl@tempdimc){\textbf{Hausruf:}}%
        \put(347bp,2.1\vl@tempdimc){\vl@ContactPersonTelephon}% 
      \line(1,0){\textwidth}%      
    }%
    \vl@tempdimb=363bp %
    \put(\vl@tempdima,\vl@tempdimb){%
      \vl@tempdimc=-17bp %
      \put(4bp,\vl@tempdimc){\textbf{Bei Luft-/See- oder Schienentransport   
        24\,h Notfallrufnummer des Absenders erforderlich:}}%
      \vl@tempdimc=-32bp %
      \put(4bp,\vl@tempdimc){%
        \textbf{Kontaktperson}\hspace{165bp}24\,h~Notfallrufnummer: 
      }%
      \line(1,0){\textwidth}%
    }%
    \vl@tempdimb=295bp %
    \put(\vl@tempdima,\vl@tempdimb){%
      \vl@tempdimc=-17bp %
      \put(4bp,\vl@tempdimc){%
        \parbox[t]{236bp}{%
          \textbf{Absender}~(vollständige Adresse)\par\medskip
          \vl@SenderAddress
        }%         
      }
      \put(250bp,\vl@tempdimc){%
        \parbox[t]{236bp}{%
          \textbf{Empfänger}~(vollständige Adresse)\par\medskip
          \vl@RecipientAddress
        }%         
      }%
      \line(1,0){\textwidth}%
    }%
    \vl@tempdimb=173bp %
    \put(\vl@tempdima,\vl@tempdimb){%
      \vl@tempdimc=-17bp %
      \put(4bp,\vl@tempdimc){\textbf{Bemerkungen:}}%
      \put(77bp,\vl@tempdimc){%
        \parbox[t]{409bp}{%
          \vl@Comment
        }%          
      }% 
      \line(1,0){\textwidth}%
    }%
    \vl@tempdimb=124bp %
    \put(\vl@tempdima,\vl@tempdimb){%
      \put(12bp,-34bp){\line(1,0){171}}%
      \vl@tempdimc=95bp %
      \put(\vl@tempdimc,-17bp){\makebox(0,0)[c]{%
        \ifx\vl@SignatureGraphic\@empty
          \ifx\vl@SignatureGraphicBaseLXIV\@empty\else
            % https://github.com/csachs/luaimageembed
            \includegraphicsembedded[height=26bp]{\vl@SignatureGraphicBaseLXIV}%
          \fi
        \else
          \includegraphics[height=26bp]{\vl@SignatureGraphic}%
        \fi
      }}%
      \put(\vl@tempdimc,-45bp){\makebox(0,0)[c]{Unterschrift}}% 
      \line(1,0){\textwidth}%
    }%
    %
    \vl@tempdima=397bp %
    \vl@tempdimc=147bp % kurze waag. Linien
    \put(\vl@tempdima,525bp){%
      \vl@tempdimb=-15bp %
      \put(4bp,\vl@tempdimb){\textbf{Verpackung:}~\vl@Package}%
      \line(1,0){\vl@tempdimc}%
    }%
    \put(\vl@tempdima,502bp){%
      \vl@tempdimb=-17bp %
      \put(4bp,\vl@tempdimb){%
        \parbox[t]{139bp}{\textbf{Art:}\par\medskip\vl@Type}%
      }%
      \line(1,0){\vl@tempdimc}%
    }%
    %------ Symbole ------
    \vl@tempdima=145mm %
    \vl@tempdimb=255mm %
    \vl@tempdimc=12.67mm % 
    % TODO: Evtl. Paket Grafiken von "ghsystem" verwenden?!  
    \put(\vl@tempdima,\vl@tempdimb){%
      \includegraphics[width=15mm]{Dangclass2_3.png}}%
    \advance\vl@tempdima-\vl@tempdimc
    \put(\vl@tempdima,\vl@tempdimb){%
      \includegraphics[width=15mm]{Dangclass2_2.png}}%
    \advance\vl@tempdima 3\vl@tempdimc 
    \put(\vl@tempdima,\vl@tempdimb){%
      \includegraphics[width=15mm]{Dangclass8.png}}%
    \advance\vl@tempdima-\vl@tempdimc
    \put(\vl@tempdima,\vl@tempdimb){%
      \includegraphics[width=15mm]{Dangclass3.png}}%
    %------ vertikale Linien ------
    \vl@tempdimb=694bp %
    \put(221bp,\vl@tempdimb){\line(0,-1){50bp}}%
    \put(382bp,\vl@tempdimb){\line(0,-1){50bp}}%
    \vl@tempdimb=644bp %
    \put(397bp,\vl@tempdimb){\line(0,-1){281bp}}%
    \vl@tempdimb=295bp %
    \put(299bp,\vl@tempdimb){\line(0,-1){122bp}}%
    %------ interne Nummer ------
    \put(15mm,27mm){\rotatebox[origin=c]{90}{\tiny \vl@doc@style@code}}
  }%  
}



\AtBeginDocument{%
  \mbox{} \newpage
}

\iftrue
\RequirePackage[neverdecrease]{paralist}
\let\itemize\compactitem
\let\enditemize\endcompactitem
\setdefaultleftmargin{0pt}{0pt}{0pt}{0pt}{0pt}{0pt}
\pltopsep=\medskipamount
\plitemsep=\smallskipamount
\else
\RequirePackage{enumitem}
\setlist{leftmargin=*,noitemsep}
\setlist[1]{labelindent=0em}
\fi

\emergencystretch=3em %
\pagestyle{empty}

\endinput