Don't try to save settings if none available.
[maemo-rb.git] / manual / pdfdraftcopy.sty
blob07da7eab8a3f372debd8881472d199cbaaec5311
1 %%
2 %%
3 %% This is file 'pdfdraftcopy.sty',
4 %% generated with the docstrip utility.
5 %%
6 %% The original source files were:
7 %%
8 %%
9 %% pdfdraftcopy.dtx (with options: 'package')
11 %% File: pdfdraftcopy.dtx Copyright (c) 2003, C. V. Radhakrishnan
12 %% C. V. Rajagopal
13 %% River Valley Technologies, Floor III, SJP Buildings
14 %% Cotton Hills, Trivandrum, India 695014
15 %% http://www.river-valley.com
17 %% This package may be distributed under the terms of the LaTeX Project
18 %% Public License, as described in lppl.txt in the base LaTeX distribution.
19 %% Either version 1.0 or, at your option, any later version.
21 %% $Id: pdfdraftcopy.sty,v 1.2 2003/08/11 20:31:07 cvr Exp cvr $
23 \NeedsTeXFormat{LaTeX2e}
24 \def\Fileversion$#1: #2 ${\gdef\fileversion{#2}}
25 \def\Filedate$#1: #2 #3 ${\gdef\filedate{#2}}
26 \Fileversion$Revision: 1.2 $
27 \Filedate$Date: 2003/08/11 20:31:07 $
28 \ProvidesPackage{pdfdraftcopy}
29 [\filedate\space\fileversion\space Draft copy in PDF (CVR)]
30 \PackageWarningNoLine{pdfdraftcopy}
31 {****************************************\MessageBreak
32 Package pdfdraftcopy v,\fileversion\space loaded\MessageBreak
33 [Draft copy in PDF (CVR)]\MessageBreak
34 ****************************************}
35 \DeclareOption{watermark}{\AtBeginDocument{%
36 \begingroup\watermark\endgroup}}
37 \DeclareOption{draft}{\AtBeginDocument{%
38 \begingroup\draftcopy\endgroup}}
39 \ExecuteOptions{draft}
40 \ProcessOptions\relax
42 \RequirePackage{color,graphicx}
44 \let\@DRAFTout@Hook\@empty
45 \newcommand{\DRAFTout}{\g@addto@macro\@DRAFTout@Hook}
46 \newcommand{\@DRAFTout@Out}{%
47 \afterassignment\@DRAFTout@Test
48 \global\setbox\@cclv= %
50 \newcommand{\@DRAFTout@Test}{%
51 \ifvoid\@cclv\relax
52 \aftergroup\@DRAFTout@Output
53 \else
54 \@DRAFTout@Output
55 \fi%
57 \newcommand{\@DRAFTout@Output}{%
58 \@DRAFTout@Hook%
59 \@DRAFTout@Org@Out\box\@cclv%
61 \newcommand{\@DRAFTout@Org@Out}{}
62 \newcommand*{\@DRAFTout@Init}{%
63 \let\@DRAFTout@Org@Out\shipout
64 \let\shipout\@DRAFTout@Out
66 \AtBeginDocument{\@DRAFTout@Init}
67 \newcommand{\@DraftOverlay@Hook}{}
68 \newcommand{\AddToDraftOverlay}{\g@addto@macro\@DraftOverlay@Hook}
69 \newcommand{\ClearDraftOverlay}{\let\@DraftOverlay@Hook\@empty}
70 \newcommand{\@DraftOverlay}{%
71 \ifx\@DraftOverlay@Hook\@empty
72 \else
73 \bgroup
74 \@tempdima=1in
75 \@tempcnta=\@tempdima
76 \@tempcntb=-\@tempdima
77 \advance\@tempcntb\paperheight
78 \global\setbox\@cclv\vbox{%
79 \vbox{\let\protect\relax%
80 \unitlength=1sp%
81 \pictur@(0,0)(\@tempcnta,\@tempcntb)%
82 \@DraftOverlay@Hook%
83 \endpicture}%
84 \box\@cclv%
86 \egroup
87 \fi
90 \definecolor{gray30}{gray}{.7}
91 \definecolor{gray20}{gray}{.8}
92 \definecolor{gray10}{gray}{.9}
94 \DRAFTout{\@DraftOverlay}
95 \newdimen\LLY
96 \newdimen\LLX
97 \newdimen\URX
98 \newdimen\URY
99 \newdimen\topmargin
100 \newdimen\bottommargin
101 \def\@printdimen{%\ifthenelse{\equal{\@debug}{true}}%
102 {\PackageWarningNoLine{PDFdraftcopy}%
103 {\LLX::::::::::::=\the\LLX\MessageBreak
104 \LLY::::::::::::=\the\LLY\MessageBreak
105 \URX::::::::::::=\the\URX\MessageBreak
106 \URY::::::::::::=\the\URY\MessageBreak
107 \oddsidemargin::=\the\oddsidemargin\MessageBreak
108 \evensidemargin:=\the\evensidemargin\MessageBreak
109 \textheight:::::=\the\textheight\MessageBreak
110 \textwidth::::::=\the\textwidth\MessageBreak
111 \paperwidth:::::=\the\paperwidth\MessageBreak
112 \paperheight::::=\the\paperheight\MessageBreak
113 \topmargin::::::=\the\topmargin\MessageBreak
114 \headheight:::::=\the\headheight\MessageBreak
115 \headsep::::::::=\the\headsep\MessageBreak
116 \footskip:::::::=\the\footskip\MessageBreak
117 \topskip::::::::=\the\topskip\MessageBreak
118 Now fixing the overlay in place
119 }}{}
121 \def\@DRAFTdimen{%
122 \setlength\LLY{\paperheight}
123 \addtolength\LLY{-\textheight}
124 \addtolength\LLY{-\headheight}
125 \addtolength\LLY{-\headsep}
126 \addtolength\LLY{-1in}
127 \addtolength\LLY{-3pt}
128 \setlength\LLX{1in}
129 \ifodd\c@page
130 \addtolength\LLX{\oddsidemargin}\else
131 \addtolength\LLX{\evensidemargin}\fi
132 \setlength\URX{\textwidth}
133 \setlength\URY{\textheight}
135 \def\LoadWaterMark{\watermark}
136 \def\watermark{\AddToDraftOverlay{%
137 \@DRAFTdimen%\@printdimen%
138 \setlength{\@tempdima}{0pt}
139 \setlength{\@tempdimb}{\paperwidth}
140 \addtolength{\@tempdimb}{-\@tempdima}
141 \addtolength{\@tempdimb}{-\@tempdima}
142 \setlength{\@tempdimc}{\paperheight}
143 \addtolength{\@tempdimc}{-\@tempdima}
144 \addtolength{\@tempdimc}{-\@tempdima}
145 \setlength{\unitlength}{1pt}\thinlines%
147 \put(0,\strip@pt\paperheight){\fboxrule0pt\fboxsep0pt%
148 %\fcolorbox{white}{red}%
149 {\begin{minipage}[t][\paperheight][c]{\paperwidth}
150 \centering
151 \ifx\@@watermark\@empty\relax\else
152 \includegraphics%[width=\paperwidth,height=\paperheight]%
153 {\@@watermark}\fi%
154 \end{minipage}}}}}%
156 \let\@@watermark\@empty
157 \def\watermarkgraphic#1{\gdef\@@watermark{#1}}
159 \def\draftcopy{\AddToDraftOverlay{%
160 \@DRAFTdimen%\@printdimen%
161 \setlength{\@tempdima}{0pt}
162 \setlength{\@tempdimb}{\paperwidth}
163 \addtolength{\@tempdimb}{-\@tempdima}
164 \addtolength{\@tempdimb}{-\@tempdima}
165 \setlength{\@tempdimc}{\paperheight}
166 \addtolength{\@tempdimc}{-\@tempdima}
167 \addtolength{\@tempdimc}{-\@tempdima}
168 \setlength{\unitlength}{1pt}\thinlines%
170 \put(0,\strip@pt\paperheight){\fboxrule0pt\fboxsep0pt%
171 %\fcolorbox{white}{red}%
172 {\begin{minipage}[t][\paperheight][c]{\paperwidth}
173 \centering
174 \begingroup
175 \rotatebox{\@draftangle}{\color{\@draftcolor}
176 \fontfamily{\@draftfontfamily}%
177 \fontsize{\@draftfontsize}{\@draftfontsize}\selectfont
178 {\@draftfontattrib\@draftstring}
179 }\endgroup
180 \end{minipage}}}}}%
182 \def\@draftangle{45}
183 \def\@draftstring{DRAFT COPY}
184 \def\@draftcolor{gray10}
185 \def\@draftfontfamily{ptm}
186 \def\@draftfontsize{80}
187 \def\@draftfontattrib{\upshape}
188 \def\draftstring#1{\gdef\@draftstring{#1}}
189 \def\draftcolor#1{\gdef\@draftcolor{#1}}
190 \def\draftfontfamily#1{\gdef\@draftfontfamily{#1}}
191 \def\draftfontsize#1{\gdef\@draftfontsize{#1}}
192 \def\draftfontattrib#1{\gdef\@draftfontattrib{#1}}
193 \def\draftangle#1{\gdef\@draftangle{#1}}
194 \endinput
197 %% End of package 'pdfdraftcopy.sty'