%%
%% This is file `aeb_envelope.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% aeb_envelope.dtx  (with options: `copyright,package')
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% aeb_envelope.sty package,          2007-05-14        %%
%% Copyright (C) 2006  D. P. Story                      %%
%%   dpstory@acrotex.net                                %%
%%   storyd@owc.edu                                     %%
%%                                                      %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License        %%
%% Distributed from CTAN archives in directory          %%
%% macros/latex/base/lppl.txt; either version 1 of the  %%
%% License, or (at your option) any later version.      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{aeb_envelope}
 [2007/05/14 v1.0 AeB Pro eEnvelope (dps)]
    % the eEnvelope out to your recipients.
\RequirePackage{xkeyval}
\DeclareOptionX{donotmail}{\def\mailitNow{false}}
\def\mailitNow{true}
\DeclareOptionX{path2folder}{\def\aebEnvPath{#1}}
\def\aebEnvPath{/C}
\define@choicekey+{aeb_envelope.sty}{envelope}[\val\nr]{aeb1,aeb2,adobe1,adobe2}
{%
    \ifcase\nr\relax
        \def\pathtoEnv{\aebEnvPath/aebenvelope1.pdf}
        \def\addressEnv{\addressEnvAebi}
        \def\aebenvDimensions{\margins{0pt}{0pt}{0pt}{0pt}%
            \screensize{50mm}{112mm}}
    \or
        \def\pathtoEnv{\aebEnvPath/aebenvelope2.pdf}
        \def\addressEnv{\addressEnvAebii}
        \def\aebenvDimensions{\margins{0pt}{0pt}{0pt}{0pt}%
            \screensize{50mm}{112mm}}
    \or
        \def\pathtoEnv{\aebEnvPath/template1.pdf}
        \def\addressEnv{\addressEnvAdobei}
        \def\aebenvDimensions{\margins{0pt}{0pt}{0pt}{0pt}%
            \screensize{135.5mm}{212.7mm}}
    \or
        \def\pathtoEnv{\aebEnvPath/template2.pdf}
        \def\addressEnv{\addressEnvAdobeii}
        \def\aebenvDimensions{\margins{0pt}{0pt}{0pt}{0pt}%
            \screensize{120mm}{250mm}}
    \fi
}{\PackageWarning{aeb_envelope}{%
    Bad choice for the envelope, permissible values\MessageBreak
    are aeb1,aeb2,adobe1 and adobe2.\MessageBreak
    Assuming a custom envelope, \val.\MessageBreak
    Be sure to set the values of \string\addressEnv\MessageBreak
    and \string\aebenvDimensions}%
    \def\pathtoEnv{\aebEnvPath/\val}%
}
\def\pathtoEnv{\aebEnvPath/aebenvelope1.pdf}
\newcommand{\setAddressEnv}[1]{\def\addressEnv{\noindent#1}}
\def\addressEnv{\addressEnvAebi}
\newcommand{\setEnvDimensions}[2]% #1 = width, #2 = height
    {\def\aebenvDimensions{\margins{0pt}{0pt}{0pt}{0pt}%
        \screensize{#2}{#1}}}
\setEnvDimensions{112mm}{50mm}
\InputIfFileExists{envelope.cfg}{}{}
\ProcessOptionsX
\RequirePackage{graphicx}
\RequirePackage{aeb_pro}
\define@boolkey{mailto}[mailto]{UI}[true]{}
\define@key{mailto}{ToName}{\def\mailtoName{#1}}
\define@key{mailto}{From}{\def\mailtoFrom{#1}}
\define@key{mailto}{To}{\def\mailtoEmail{#1}}
\define@key{mailto}{path}{\def\pathtoEnv{#1}}
\define@key{mailto}{CC}{\def\mailtoCC{#1}}
\define@key{mailto}{BCC}{\def\mailtoBCC{#1}}
\define@key{mailto}{Subject}{\def\mailtoSubject{#1}}
\define@key{mailto}{MessageEnvelope}{\def\mailtoMessageEnvelope{#1}}
\define@key{mailto}{MessageBody}{\def\mailtoMessageBody{#1}}
\mailtoUItrue
\def\mailtoUI{\ifmailtoUI true\else false\fi}
\let\mailtoName\@empty
\let\mailtoEmail\@empty
\let\mailtoCC\@empty
\let\mailtoBCC\@empty
\let\mailtoSubject\@empty
\let\mailtoMessageEnvelope\@empty
\let\mailtoMessageBody\@empty
\newcommand\mailTo[1]{\setkeys{mailto}{#1}}
\@ifpackageloaded{eforms}
{
    \providecommand{\toggleAttachmentsPanel}[2]{%
        \setLinkText[\Border{0 0 0}\A{/N/ShowHideFileAttachment/S/Named}]
        {\textcolor{#1}{#2}}}%
}{%
        \providecommand{\toggleAttachmentsPanel}[2]{\textcolor{#1}{#2}}%
}
\def\displayAddr#1{\makebox[0pt][r]{\makebox[.6in][r]{#1:}\enspace}\ignorespaces}
\newcommand{\addressEnvAebi}
{%
    \noindent\put(125,60){%
    \begin{minipage}[t]{2in}\parindent0pt\raggedright\small
         \displayAddr{To}\mailtoName\\
         \displayAddr{From}\mailtoFrom\\
         \displayAddr{Message}\mailtoMessageEnvelope
    \end{minipage}}%
}
\newcommand{\addressEnvAebii}
{%
    \small
    \noindent
    \put(12,120){\mailtoFrom}%
    \put(100,60){\makebox[0pt][r]{To:\enspace}\mailtoName}%
    \put(100,45){\makebox[0pt][r]
        {Message:\enspace}\parbox[t]{120pt}
        {\raggedright\mailtoMessageEnvelope}}%
}
\newcommand{\addressEnvAdobei}
{%
    \large
    \noindent\put(32,160){\today}%
    \put(32,120){\parbox[t]{540pt}{\mailtoMessageEnvelope}}%
    \put(189,160){\mailtoName}%
    \put(390,160){\mailtoFrom}%
}

\newcommand{\addressEnvAdobeii}
{%
    \Large
    \noindent\put(334.5,90){\parbox[t]{250pt}{\mailtoMessageEnvelope}}%
    \put(364,119){\mailtoName}%
    \put(90,305){\mailtoFrom}%
}
\def\inputEnvExecJS{\InputIfFileExists{envexecjs.def}{}}
\newcommand{\assembleEnvelope}
{%
    \par\aebenvDimensions
    \setlength{\unitlength}{1pt}%
    \AddToTemplate{addressEnv}
    \inputEnvExecJS
    \par\begin{document}\parskip0pt\strut\end{document}
}
\thispagestyle{empty}
\endinput
%%
%% End of file `aeb_envelope.sty'.
