summaryrefslogtreecommitdiff
path: root/texmf-dist/source/latex/aebenvelope/aeb_envelope.dtx
blob: 66fa194d13ae3835a5d6a294fca8e9de517ae675 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
% \iffalse
%<*copyright>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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.      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</copyright>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{aeb_envelope}
%<package> [2007/05/14 v1.0 AeB Pro eEnvelope (dps)]
%<*driver>
\documentclass{ltxdoc}
\usepackage[dviwindo,colorlinks,hyperindex]{hyperref}
\pdfstringdefDisableCommands{\let\\\textbackslash}%
\EnableCrossrefs \CodelineIndex
\OnlyDescription  % comment out for implementation details
\begin{document}
  \GetFileInfo{aeb_envelope.sty}
  \title{The \textsf{AeB Pro eEnvelope} Package\texorpdfstring{\\}{: }
  A member of the AeB Pro family}
  \author{D. P. Story\\
    Email: \texttt{storyd@owc.edu}}
  \date{processed \today}
  \maketitle
  \tableofcontents
  \let\Email\texttt
  \DocInput{aeb_envelope.dtx}
  \PrintIndex
\end{document}
%</driver>
% \fi
% \section{Introduction}
% The \textsf{AeB Pro eEnvelope} package (a.k.a. \texttt{aeb\_envelope}) is a package for creating
% electronic envelopes (some designs provided, courtesy Adobe and AcroTeX.Net), and some instructions
% for creating your own are provided in the documentation. The AeB Pro package is essential for attach
% your documents to the envelope.  After attachment, a mail dialog opens and you are asked to sent
    % the eEnvelope out to your recipients.
%    \begin{macrocode}
%<*package>
\RequirePackage{xkeyval}
%    \end{macrocode}
%    \begin{macro}{donotmail}
% Do not mail this eEnvelope immediately. The default is to mail immediately.
%    \begin{macrocode}
\DeclareOptionX{donotmail}{\def\mailitNow{false}}
\def\mailitNow{true}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{path2folder}
% The path to the folder that contains the eEnvelope templates. Not needed if you use
% the set the envelope.cfg file to the path to the envelopes folder.
%    \begin{macrocode}
\DeclareOptionX{path2folder}{\def\aebEnvPath{#1}}
\def\aebEnvPath{/C}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{envelope}
% The \texttt{envelope} option is used to select any of the four supplied envelopes: \texttt{aeb1},
% \texttt{aeb2}, \texttt{adobe1} and \texttt{adobe2}. the default is \texttt{aeb1}.
%    \begin{macrocode}
\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}%
}
%    \end{macrocode}
%    \end{macro}
% Set the defaults for the \texttt{envelope} option. If the user specifies \texttt{path2folder},
% this choice overrides the configuration file.
%    \begin{macrocode}
\def\pathtoEnv{\aebEnvPath/aebenvelope1.pdf}
%    \end{macrocode}
%    \begin{macro}{\setAddressEnv}
%    \begin{macro}{\setEnvDimensions}
% These are two convenience commands to be used by anyone who want to create
% and use their own eEnvelope. Use \cs{setAddressEnv} to place the elements
% of the envelope; and \cs{setEnvDimensions} to set the dimensions of the papersize
% to match the dimensions of the eEnvelope.
%
% The argument of \cs{setAddressEnv} should be \cs{put} commands, similar to the
% definitions of \cs{addressEnvAebi}, \cs{addressEnvAebii}, \cs{addressEnvAdobei}
% or \cs{addressEnvAdobeii}.
%    \begin{macrocode}
\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}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
% Get the configuration file, if it exists. The
%    \begin{macrocode}
\InputIfFileExists{envelope.cfg}{}{}
\ProcessOptionsX
\RequirePackage{graphicx}
\RequirePackage{aeb_pro}
%    \end{macrocode}
% \section{Main Macro Code}
% eEnvelope!
%    \begin{macro}{\mailTo}
% The main data structure for setting the parameters of the eEnvelope,
%    \begin{macrocode}
\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
%    \end{macrocode}
% With the preliminaries of defining the parameters, here is the defiinition
% of \cs{mailTo}.
%    \begin{macrocode}
\newcommand\mailTo[1]{\setkeys{mailto}{#1}}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\toggleAttachmentsPanel}
% A convenience command that toggles the attachments panel. The first parameter
% is the color of the text, the second parameter is the text. Sample usage
% \verb!\toggleAttachmentsPanel{red}{Click to view attachments}!
% If user does not have eforms loaded, then this command just typesets the text
% rather than creating a link with action.
%    \begin{macrocode}
\@ifpackageloaded{eforms}
{
    \providecommand{\toggleAttachmentsPanel}[2]{%
        \setLinkText[\Border{0 0 0}\A{/N/ShowHideFileAttachment/S/Named}]
        {\textcolor{#1}{#2}}}%
}{%
        \providecommand{\toggleAttachmentsPanel}[2]{\textcolor{#1}{#2}}%
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
\def\displayAddr#1{\makebox[0pt][r]{\makebox[.6in][r]{#1:}\enspace}\ignorespaces}
%    \end{macrocode}
%    \begin{macro}{\addressEnvAebi}
%    \begin{macro}{\addressEnvAebii}
%    \begin{macro}{\addressEnvAdobei}
%    \begin{macro}{\addressEnvAdobeii}
% The commands to put address info on the envelope, each correspond to
% the four envelope option: \texttt{aeb1}, \texttt{aeb2}, \texttt{adobe1}
% and \texttt{adobe2}, in that order.
%    \begin{macrocode}
\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}%
}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \begin{macro}{\assembleEnvelope}
% The end of the eEnvelope file must have this command, it replaces the
% \verb!\begin{document}! and \verb!\end{document}! environment.
%
% \texttt{envexecjs.def} inputs the doc assembly commands for inserting the background
% of the eEnvelope.
%    \begin{macrocode}
\def\inputEnvExecJS{\InputIfFileExists{envexecjs.def}{}}
\newcommand{\assembleEnvelope}
{%
    \par\aebenvDimensions
    \setlength{\unitlength}{1pt}%
    \AddToTemplate{addressEnv}
    \inputEnvExecJS
    \par\begin{document}\parskip0pt\strut\end{document}
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
%</package>
%<*envexecjs>
%    \end{macrocode}
% These are the after distill document assembly commands. We insert the
% eEnvelope file as background, we define the \texttt{mailItNow()} function to mail
% the package if the mail dialog is dismissed or if the document author
% used the \texttt{donotmail} option. Mail data is saved as a global variable
% \texttt{globa.oEmailArgs} that should be remembered by Acrobat until it is closed.
%    \begin{macrocode}
\begin{execJS}{envexecjs}
global.oEmailArgs = {
    bUI:\mailtoUI,
    cTo: "\mailtoEmail",
    cCc: "\mailtoCC",
    cBcc: "\mailtoBCC",
    cSubject: "\mailtoSubject",
    cMsg: "\mailtoMessageBody"
};
\addWatermarkFromFile({
    bOnTop:false,
    cDIPath:"\pathtoEnv"
});
function mailItNow()
{
    try { this.mailDoc(global.oEmailArgs) } catch(e) {}
}
console.println("mailItNow();");
\executeSave();
if ( \mailitNow\space)
    aebTrustedFunctions(this, aebMailDoc, global.oEmailArgs);
\end{execJS}
%    \end{macrocode}
%    \begin{macrocode}
%</envexecjs>
%<*package>
\thispagestyle{empty}
%</package>
%    \end{macrocode}
%  \Finale
\endinput