Debian Codegraph @

texmf-dist/tex/latex/epspdfconversion/epspdfconversion.sty

raw
1 %%
2 %% This is file `epspdfconversion.sty',
3 %%
4 %%
5 %% It is based on epstopdf.sty by Heiko Oberdiek and is a tool to use Siep
6 %% Kroonenberg's Epspdf-tools (http://tex.aanhet.net/epspdf/)
7 %% "on the fly" in LaTeX
8 %%
9 %% Please send suggestions to [email protected]
10 %%
11 %%
12 %% version history:
13 %% 0.61 * new options pdftopdf and pstopdf. Uses epspdf to do pdf-to-pdf and ps-to-pdf conversions. Allows grayscaling, calculation of
14 %% bounding boxes etc for pdf's that already exist an for .ps-files. Disabled by default.
15 %% * bugfix for the outdir-option (converted files in subdirectories are again saved in those subdirectories)
16 %% (Thanks to Stefan Pofahl for the feedback.)
17 %% * small improvement of the documentation (on the windows epspdf.bat file, on epstopdf's option 'outdir')
18 %% * now uses epstopdf's \epstopdfDeclareGraphicsRule
19 %% 0.6 * pdfversion now uses epspdf's --pdfversion. --version in epspdf is to print the
20 %% version number of epspdf (currently, epspdf is at 0.5)
21 %% * new author email
22 %% 0.5 this update makes use of changes in the epstopdf-package v2.2
23 %% * new options
24 %% update,verbose,prefersuffix,suffix,outdir
25 %% (they are really epstopdf options, but can be set
26 %% as options for this package)
27 %% * default is that converted files have a suffix
28 %% * info in logfile about the setup that is used for epstopdf
29 %% * new options hires, no-hires
30 %% 0.4: the epstopdf-package is now loaded with options [update,prepend]
31 %% (works only when epstopdf version 1.5 is used) An update of epstopd.sty
32 %% (part of the oberdiek-bundle) is recommended. Added options nogrey,nogray
33 %% 0.3: Heiko Oberdiek substantially improved the code.
34 %% The kvoptions-package is now used for the implemention of options.
35 %% See the documentation for effects and additional features.
36 %% 0.2: the package is now simply based on epstopdf. This package essentially
37 %% defines \@namedef{Gin@[email protected]}#1{{pdf}{.pdf}{`\conversioncommand #1}}
38 %% differently than epstopdf. The code has been cleaned up. Improvements of
39 %% documentation and additional warning about pdfminorversion....
40 %% 0.1: first try
41 %%
42
43
44
45
46 \NeedsTeXFormat{LaTeX2e}
47 \ProvidesPackage{epspdfconversion}%
48 [2010/06/01 v0.61 Conversion eps->pdf with epspdf-tools on the fly]
49
50
51 %% this loads the graphics, epstopdf and the kvoptions packages.
52 \RequirePackage{graphics}
53 \RequirePackage{epstopdf-base}[2009/07/16]% version 2.2 is necessary
54 \RequirePackage{kvoptions}[2006/08/22]% because of \DeclareBoolOption
55
56
57 \SetupKeyvalOptions{
58 family=EPC,
59 prefix=EPC@
60 }
61
62
63 %% this is the basic command necessary for the conversion with epspdf
64 \DeclareStringOption[epspdf]{cmd}
65
66 % Gray
67 % \EPC@gray stores the whole option
68 \DeclareVoidOption{gray}{%this is for the \usepackage[gray]{...
69 \def\EPC@optgray{--gray }%this is the effect in the command line
70 }
71 \DeclareVoidOption{GRAY}{%
72 \def\EPC@optgray{--GRAY }%
73 }
74 \DeclareVoidOption{grey}{%
75 \def\EPC@optgray{--grey }%
76 }
77 \DeclareVoidOption{GREY}{%
78 \def\EPC@optgray{--GREY }%
79 }
80 \DeclareVoidOption{nogrey}{%
81 \def\EPC@optgray{ }%
82 }
83 \DeclareVoidOption{nogray}{%
84 \def\EPC@optgray{ }%
85 }
86
87
88
89 % Target
90 % \EPC@target stores the target only
91 % target ==> --target=default
92 % target=printer ==> --target=printer
93 % screen ==> --target=screen
94 \DeclareStringOption{target}[default]
95 \DeclareVoidOption{default}{%
96 \def\EPC@target{default}%
97 }
98 \DeclareVoidOption{printer}{%
99 \def\EPC@target{printer}%
100 }
101 \DeclareVoidOption{prepress}{%
102 \def\EPC@target{prepress}%
103 }
104 \DeclareVoidOption{screen}{%
105 \def\EPC@target{screen}%
106 }
107 \DeclareVoidOption{ebook}{%
108 \def\EPC@target{ebook}%
109 }
110
111
112
113
114 % Version
115 % \EPC@pdfversion stores the version only
116 % pdfversion=1.2 ==> --pdfversion=1.2
117 % the warning with pdfminorversion does not work?
118
119 \define@key{EPC}{pdfversion}[default]{%
120 \@ifundefined{EPC@pdfversion@#1}{%
121 \PackageError{epspdfconversion}{%
122 Ignoring unknown value for `pdfversion'. Known values are: 1.2,1.3, 1.4, default%
123 }\@ehc
124 }{%
125 \def\EPC@pdfversion{#1}%
126 \begingroup
127 \let\MinorVersion\relax
128 \@ifundefined{pdfminorversion}{%
129 \@ifundefined{pdfoptionpdfminorversion}{}{%
130 \def\MinorVersion{\pdfoptionpdfminorversion}%
131 }%
132 }{%
133 \def\MinorVersion{\pdfminorversion}%
134 }%
135 \ifx\MinorVersion\relax
136 \else
137 \ifnum\@nameuse{EPC@pdfversion@#1}>\MinorVersion
138 \PackageWarning{epspdfconversion}{%
139 You have chosen pdfversion=#1,\MessageBreak
140 but you generate PDF-1.\number\MinorVersion.%
141 \MessageBreak
142 This can be changed by\MessageBreak
143 \expandafter\string\MinorVersion=%
144 \@nameuse{EPC@pdfversion@#1}%
145 \MessageBreak
146 (at the very beginning of your .tex file).\MessageBreak Or try `pdfversion=1.\number\MinorVersion'%
147 }%
148 \fi
149 \fi
150 \endgroup
151 }%
152 }
153
154 \@namedef{EPC@[email protected]}{2}
155 \@namedef{EPC@[email protected]}{3}
156 \@namedef{EPC@[email protected]}{4}
157 \@namedef{EPC@pdfversion@default}{0}% disable version check
158
159 % bbox ==> --bbox
160 % bbox=true ==> --bbox
161 % bbox=false ==> option disabled
162 \DeclareBoolOption{bbox}
163
164 %support for pdftopdf-conversion
165 \DeclareBoolOption{pdftopdf}
166
167 %support for pstopdf-conversion
168 \DeclareBoolOption{pstopdf}
169
170 \DeclareVoidOption{pdftops}{%
171 \def\EPC@optpdftops{-U }%
172 }
173 \DeclareVoidOption{nopdftops}{%
174 \def\EPC@optpdftops{-I }%
175 }
176
177 \DeclareVoidOption{hires}{%
178 \def\EPC@opthires{--hires }%
179 }
180 \DeclareVoidOption{no-hires}{%
181 \def\EPC@opthires{--no-hires }%
182 }
183
184 \DeclareStringOption{custom}
185 \DeclareStringOption{psoptions}
186 \DeclareStringOption{pagenumber}
187
188 \DeclareVoidOption{simple}{%
189 % disable other options
190 \let\EPC@optgray\@empty
191 \let\EPC@optpdftops\@empty
192 \let\EPC@opthires\@empty
193 \let\EPC@target\@empty
194 \let\EPC@pdfversion\@empty
195 \let\EPC@custom\@empty
196 \let\EPC@psoptions\@empty
197 \let\EPC@pagenumber\@empty
198 \EPC@bboxfalse
199 }
200
201 % default setting: all options cleared
202 \EPC@simple
203
204 % Options help works immediately, if shell escape feature is enabled.
205 \DeclareVoidOption{help}{%
206 \immediate\write18{\EPC@cmd\space--help}%
207 }
208
209 \def\EPC@addopt#1{%
210 \expandafter\ifx\csname EPC@#1\endcsname\@empty
211 \else
212 --#1=\@nameuse{EPC@#1} %
213 \fi
214 }
215
216 %% this is the setup of the command line....
217 \newcommand*{\epspdfconversioncmdline}[1]{%
218 \EPC@cmd\space
219 \EPC@optpdftops
220 \EPC@opthires
221 \EPC@addopt{target}%
222 \ifx\EPC@pdfversion\@empty
223 \else
224 --pdfversion=\EPC@pdfversion\space
225 \fi
226 \EPC@addopt{custom}%
227 \EPC@addopt{psoptions}%
228 \EPC@addopt{pagenumber}%
229 \ifEPC@bbox
230 --bbox %
231 \else
232 \fi
233 \EPC@optgray
234 #1%
235 }
236
237 %% message in the log-file:
238 \def\EPC@printlog{\PackageInfo{epspdfconversion}{\MessageBreak%
239 \epspdfconversioncmdline{<file>} is used to convert eps->pdf \MessageBreak(not epstopdf (script))\MessageBreak
240 }%
241 }
242
243
244 %% this allows to change the options on the fly
245 % Use example: \epspdfconversionsetup{target=prepress,bbox}
246 \newcommand*{\epspdfconversionsetup}[1]{%
247 \setkeys{EPC}{#1}%
248 \EPC@printlog
249 }
250 %%%%% epstopdf-options .....
251
252 % update, default is true, can be set as update=false
253 \DeclareBoolOption[true]{update}
254 % verbose, default is true, can be set as verbose=false
255 \DeclareBoolOption[true]{verbose}
256 % if there is original.pdf and original-suffix.pdf, prefer original-suffix.pdf
257 % (the one that has been generated by epspdf), can be set as prefersuffix=false
258 \DeclareBoolOption[true]{prefersuffix}
259 % suffix. Avoids accidental overwriting of files.
260 % usage: suffix={bla}
261 \DeclareStringOption[-epspdf-to]{suffix}
262 % specifies an outdir, default is current directory ...
263 \DeclareStringOption{outdir}
264
265 \DeclareBoolOption[false]{prepend}
266
267
268
269
270 % Important: !!!
271 \ProcessKeyvalOptions*
272
273 \typeout{%
274 ^^Jepspdfconversion.sty is using epstopdf.sty with the following setup:}
275
276 % use them to set epstopdf up
277 % update
278 \ifEPC@update
279 \epstopdfsetup{update=true}%
280 \typeout{\space\space\space\space update=true,}%
281 \else
282 \epstopdfsetup{update=false}%
283 \typeout{\space\space\space\space update=false,}%
284 \fi
285 % verbose
286 \ifEPC@verbose
287 \epstopdfsetup{verbose=true}%
288 \typeout{\space\space\space\space verbose=true,}%
289 \else
290 \epstopdfsetup{verbose=false}%
291 \typeout{\space\space\space\space verbose=false,}%
292 \fi
293 % prefersuffix
294 \ifEPC@prefersuffix
295 \epstopdfsetup{prefersuffix=true}%
296 \typeout{\space\space\space\space prefersuffix=true,}%
297 \else
298 \epstopdfsetup{prefersuffix=false}%
299 \typeout{\space\space\space\space prefersuffix=false,}%
300 \fi
301 % suffix
302 \epstopdfsetup{suffix=\EPC@suffix}%
303 \typeout{\space\space\space\space suffix=\EPC@suffix,}%
304
305 % outdir
306 \let\CheckOutdir\EPC@outdir
307 \ifx\CheckOutdir\@empty
308 \typeout{\space\space\space\space option outdir not set. Default: same directory as the .eps-source-file}%
309 \else
310 \epstopdfsetup{outdir={\EPC@outdir}}%
311 \typeout{\space\space\space\space outdir=\EPC@outdir}%
312 \fi
313
314 % prepend
315 \ifEPC@prepend
316 \epstopdfsetup{prepend}%
317 \typeout{\space\space\space\space prepend,}%
318 \else
319 \epstopdfsetup{append}%
320 \typeout{\space\space\space\space append,}%
321 \fi
322 % enable
323 \epstopdfsetup{enable}%
324 \typeout{\space\space\space\space enable}%
325
326
327 % another message...
328 \typeout{epspdf is used with the following command:}
329 \typeout{\space\space\space\space \epspdfconversioncmdline{<file>} }
330
331
332
333
334 \EPC@printlog
335
336
337 %%% the main functionality of this package:
338 %%% this changes the definition provided by epstopdf:
339
340 % previously, I used:
341 %\@namedef{Gin@[email protected]}#1{{pdf}{.pdf}{`\epspdfconversioncmdline{#1} \OutputFile}}
342
343 % since version 0.61: use the mechanism provided by epstopdf to define the eps-pdf conversion rule:
344
345 \epstopdfDeclareGraphicsRule{.eps}{pdf}{.pdf}{%
346 \epspdfconversioncmdline #1 \OutputFile
347 }
348
349 % pdftopdf
350 \ifEPC@pdftopdf
351 \epstopdfDeclareGraphicsRule{.pdf}{pdf}{.pdf}{%
352 \epspdfconversioncmdline #1 \OutputFile
353 }
354 \typeout{support for pdf-to-pdf is ENABLED}%
355 \typeout{}
356 \else
357 \typeout{support for pdf-to-pdf is DISABLED}%
358 \typeout{}
359 \fi
360
361 % pstopdf
362 \ifEPC@pstopdf
363 \epstopdfDeclareGraphicsRule{.ps}{pdf}{.pdf}{%
364 \epspdfconversioncmdline #1 \OutputFile
365 }
366 \typeout{support for ps-to-pdf is ENABLED}%
367 \typeout{}
368 \else
369 \typeout{support for ps-to-pdf is DISABLED}%
370 \typeout{}
371 \fi
372
373
374
375 \endinput