| 1 |
% \iffalse |
| 2 |
% |
| 3 |
% Copyright (C) 2010, 2012, 2013 by Karl Wette |
| 4 |
% |
| 5 |
% This file may be distributed and/or modified under the conditions of |
| 6 |
% the LaTeX Project Public License, either version 1.2 of this license |
| 7 |
% or (at your option) any later version. The latest version of this |
| 8 |
% license is in: |
| 9 |
% |
| 10 |
% http://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
% and version 1.2 or later is part of all distributions of LaTeX version |
| 13 |
% 1999/12/01 or later. |
| 14 |
% |
| 15 |
%<*driver> |
| 16 |
\iffalse |
| 17 |
%</driver> |
| 18 |
%<*readme> |
| 19 |
|
| 20 |
autopdf - automatic conversion of various graphics formats to |
| 21 |
pdfLaTeX-compatible graphics |
| 22 |
|
| 23 |
Run pdfLaTeX on the master DocStrip file (autopdf.dtx) to generate this |
| 24 |
README, the package style file (autopdf.sty), and the documentation |
| 25 |
(autopdf.pdf). |
| 26 |
|
| 27 |
Changelog: |
| 28 |
* v1.0 (2012/04/22): |
| 29 |
- Initial version |
| 30 |
* v1.1 (2013/12/10): |
| 31 |
- Always use identify to read size of images (even EPS files); |
| 32 |
graphicx seems to no longer support EPS file reading in PDF mode |
| 33 |
|
| 34 |
%</readme> |
| 35 |
%<*driver> |
| 36 |
\fi |
| 37 |
\begingroup |
| 38 |
\input{docstrip.tex} |
| 39 |
\keepsilent |
| 40 |
\usedir{tex/latex/autopdf} |
| 41 |
\preamble |
| 42 |
This is a generated file. |
| 43 |
|
| 44 |
Copyright (C) 2010, 2012, 2013 by Karl Wette |
| 45 |
|
| 46 |
This file may be distributed and/or modified under the conditions of |
| 47 |
the LaTeX Project Public License, either version 1.2 of this license |
| 48 |
or (at your option) any later version. The latest version of this |
| 49 |
license is in: |
| 50 |
|
| 51 |
http://www.latex-project.org/lppl.txt |
| 52 |
|
| 53 |
and version 1.2 or later is part of all distributions of LaTeX version |
| 54 |
1999/12/01 or later. |
| 55 |
\endpreamble |
| 56 |
\postamble |
| 57 |
\endpostamble |
| 58 |
\generate{ |
| 59 |
\file{autopdf.sty}{\from{autopdf.dtx}{package}} |
| 60 |
\file{README.txt}{\from{autopdf.dtx}{readme}} |
| 61 |
} |
| 62 |
\endgroup |
| 63 |
%</driver> |
| 64 |
%<*driver|package> |
| 65 |
\NeedsTeXFormat{LaTeX2e}[2005/08/01] % pdfTeX 3.141592-1.30.0 |
| 66 |
%</driver|package> |
| 67 |
%<*package> |
| 68 |
\ProvidesPackage{autopdf}[2013/12/10 v1.1 Automatically convert between graphics file formats] |
| 69 |
%</package> |
| 70 |
%<*driver> |
| 71 |
\ProvidesFile{autopdf.dtx} |
| 72 |
\documentclass[a4paper]{ltxdoc} |
| 73 |
\usepackage{autopdf}[2012/04/22] |
| 74 |
\begin{document} |
| 75 |
\DocInput{autopdf.dtx} |
| 76 |
\end{document} |
| 77 |
%</driver> |
| 78 |
% |
| 79 |
% \fi |
| 80 |
% |
| 81 |
% \CheckSum{1014} |
| 82 |
% |
| 83 |
% \CharacterTable |
| 84 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 85 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 86 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 87 |
% Exclamation \! Double quote \" Hash (number) \# |
| 88 |
% Dollar \$ Percent \% Ampersand \& |
| 89 |
% Acute accent \' Left paren \( Right paren \) |
| 90 |
% Asterisk \* Plus \+ Comma \, |
| 91 |
% Minus \- Point \. Solidus \/ |
| 92 |
% Colon \: Semicolon \; Less than \< |
| 93 |
% Equals \= Greater than \> Question mark \? |
| 94 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 95 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 96 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 97 |
% Right brace \} Tilde \~} |
| 98 |
% |
| 99 |
% |
| 100 |
% \GetFileInfo{autopdf.sty} |
| 101 |
% |
| 102 |
% \title{The \textsf{autopdf} package\thanks{ |
| 103 |
% This document corresponds to \textsf{autopdf}~\fileversion, dated \filedate.}} |
| 104 |
% \author{Karl Wette} |
| 105 |
% |
| 106 |
% \maketitle |
| 107 |
% |
| 108 |
% \section{Introduction} |
| 109 |
% |
| 110 |
% This package facilitates the conversion of various graphics formats to |
| 111 |
% formats supported by pdf\LaTeX\ (e.g.\ PDF). It has the following features: |
| 112 |
% |
| 113 |
% \begin{itemize} |
| 114 |
% |
| 115 |
% \item It uses Ghostscript\footnote{\texttt{http://www.ghostscript.com/}} |
| 116 |
% and GraphicsMagick\footnote{\texttt{http://www.graphicsmagick.org/}} to |
| 117 |
% perform graphics conversions, and therefore can convert any graphics |
| 118 |
% formats that are understood by GraphicsMagick. (If only conversion from |
| 119 |
% EPS to PDF conversion is needed, only Ghostscript is required.) |
| 120 |
% Hybrid \LaTeX/EPS graphics, as produced by e.g.\ Gnuplot, as also supported. |
| 121 |
% \textsf{autopdf} always produces a separate file for each converted graphic. |
| 122 |
% |
| 123 |
% \item Graphics conversion is performed on the fly, i.e.\ as pdf\LaTeX\ processes |
| 124 |
% the document. For this to work, pdf\LaTeX\ must be run in ``shell escape'' mode, |
| 125 |
% so that calls to Ghostscript and GraphicsMagick can be executed. Aside from |
| 126 |
% Ghostscript and GraphicsMagick, no other external programs or scripts are required. |
| 127 |
% |
| 128 |
% \item When converting EPS or \LaTeX/EPS graphics, a wrapper \LaTeX\ file is generated |
| 129 |
% to encapsulate the EPS graphic. \textsf{autopdf} tries to transfer relevant |
| 130 |
% properties of the parent document, such as the current font, to the wrapper |
| 131 |
% \LaTeX\ file, so that any \LaTeX\ typesetting in the graphic has a similar look to the |
| 132 |
% rest of the documents. Custom \LaTeX\ commands can also be easily transferred to the |
| 133 |
% wrapper \LaTeX\ file, and special support is provided for |
| 134 |
% \textsf{PSfrag}\footnote{\texttt{http://www.ctan.org/pkg/psfrag}}. |
| 135 |
% |
| 136 |
% \item After conversion, MD5 checksums of each input graphic and any associated files |
| 137 |
% are stored. When pdf\LaTeX\ is next run, the checksums are used to determine whether |
| 138 |
% any part of the graphic has changed, and therefore whether a re-conversion is needed. |
| 139 |
% |
| 140 |
% \end{itemize} |
| 141 |
% |
| 142 |
% There are also a wide variety of graphics conversion packages available on |
| 143 |
% CTAN\footnote{\texttt{http://www.ctan.org/}}, particularly for the conversion |
| 144 |
% of EPS graphics to PDF. Depending on your needs, one of these packages may |
| 145 |
% be better suited. Many of the features of \textsf{autopdf} were inspired by |
| 146 |
% the features provided by the |
| 147 |
% \textsf{epstopdf}\footnote{\texttt{http://www.ctan.org/pkg/epstopdf}} |
| 148 |
% and |
| 149 |
% \textsf{auto-pst-pdf}\footnote{\texttt{http://www.ctan.org/pkg/auto-pst-pdf}} |
| 150 |
% packages, and the |
| 151 |
% \textsf{fragmaster.pl}\footnote{\texttt{http://ratnuu.blogspot.de/2007/02/using-psfrag-with-pdflatex-useful.html}} |
| 152 |
% script. |
| 153 |
% |
| 154 |
% \section{Usage} |
| 155 |
% |
| 156 |
% Include the package: |
| 157 |
% \begin{verbatim} |
| 158 |
% \usepackage[options...]{autopdf}\end{verbatim} |
| 159 |
% Available options are: |
| 160 |
% \begin{description} |
| 161 |
% |
| 162 |
% \item[from] Default file extension of input graphics files; used if no file extension |
| 163 |
% is present in the file name given to \verb|\includegraphics|. |
| 164 |
% Defaults to \verb|.eps|. |
| 165 |
% |
| 166 |
% \item[to] Default file extension of output graphics files; determines what format |
| 167 |
% graphics are converted to. |
| 168 |
% Defaults to \verb|.pdf|. |
| 169 |
% |
| 170 |
% \item[logfile] File extension of the log file which records the checksums of converted |
| 171 |
% graphics files. The full file name is created by prepending the name of the current document, |
| 172 |
% i.e.\ \verb|\jobname.|\textit{logfile}. |
| 173 |
% Defaults to \verb|autopdf_log|. |
| 174 |
% |
| 175 |
% \item[nologfile] Takes no arguments; prevents the log file being created. |
| 176 |
% |
| 177 |
% \item[showcmds] Print the command lines calling Ghostscript/GraphicsMagick to the |
| 178 |
% pdf\LaTeX\ log file as they are executed. |
| 179 |
% Values are \verb|true| or \verb|false| (default). |
| 180 |
% |
| 181 |
% \item[cleanup] Remove intermediate files after a successful conversion. |
| 182 |
% Values are \verb|true| (default) or \verb|false|. |
| 183 |
% |
| 184 |
% \item[scale] Scale input (\LaTeX/)EPS graphic as they are converted, using any arguments |
| 185 |
% supplied to \verb|\includegraphics|. |
| 186 |
% Values are \verb|true| (default) or \verb|false|. |
| 187 |
% |
| 188 |
% \item[margin] Add an additional margin to input (\LaTeX/)EPS graphics. |
| 189 |
% Defaults to 0pt. |
| 190 |
% |
| 191 |
% \item[resolution] Specifies the resolution of the output graphics, in dots per inch. |
| 192 |
% Defaults to 600. |
| 193 |
% |
| 194 |
% \item[gscmd] Specifies the name of the Ghostscript command. |
| 195 |
% Defaults to \verb|gswin64c| (on Windows) or \verb|gs| (Linux, Mac). |
| 196 |
% Note that any spaces in this option must be replaced by \verb|~|. |
| 197 |
% |
| 198 |
% \item[gmidentifycmd] Specifies the name of the GraphicsMagick \verb|identify| command. |
| 199 |
% Defaults to \verb|gm~identify|. |
| 200 |
% Note that any spaces in this option must be replaced by \verb|~|. |
| 201 |
% |
| 202 |
% \item[gmconvertcmd] Specifies the name of the GraphicsMagick \verb|convert| command. |
| 203 |
% Defaults to \verb|gm~convert|. |
| 204 |
% Note that any spaces in this option must be replaced by \verb|~|. |
| 205 |
% |
| 206 |
% \end{description} |
| 207 |
% Apart from at package inclusion, options to \textsf{autopdf} may be modified with the |
| 208 |
% \verb|\autopdfoptions{options...}| command. This command respects \TeX\ ``scope'', e.g. |
| 209 |
% so a call to \verb|\autopdfoptions| within a \verb|\begin{figure}...\end{figure}| |
| 210 |
% environment will only affect graphics included for that particular figure. |
| 211 |
% |
| 212 |
% Once the package is included, \verb|\includegraphics| may be used as normal to |
| 213 |
% include graphics; \textsf{autopdf} will perform any conversions as needed on the fly. |
| 214 |
% For this to work, pdf\LaTeX\ must be run in ``shell escape'' mode, which requires |
| 215 |
% adding on of the following options to the pdf\LaTeX\ command line: |
| 216 |
% \begin{itemize} |
| 217 |
% \item Linux, Mac: \verb|-shell-escape|. |
| 218 |
% \item MiKTeX (Windows): \verb|--enable-write18|. |
| 219 |
% \end{itemize} |
| 220 |
% |
| 221 |
% To include custom \LaTeX\ commands in a (\LaTeX/)EPS graphic, use the |
| 222 |
% \verb|\autopdfinclude...\autopdfendinclude| command: |
| 223 |
% \begin{verbatim} |
| 224 |
% \autopdfinclude |
| 225 |
% \usepackage{amssymb} |
| 226 |
% \newcommand{\fdot}{\dot{f}} |
| 227 |
% \autopdfendinclude\end{verbatim} |
| 228 |
% All \LaTeX\ commands between \verb|\autopdfinclude| and \verb|\autopdfendinclude| will |
| 229 |
% be included in both the parent document and the wrapper \LaTeX\ file. |
| 230 |
% |
| 231 |
% To include \textsf{PSfrag} replacements in a (\LaTeX/)EPS graphic, do not use the |
| 232 |
% \textsf{PSfrag} package; instead use the replacement \verb|\autopdfpsfrag| command: |
| 233 |
% \begin{verbatim} |
| 234 |
% \autopdfpsfrag[options...]{fdot}{Frequency derivative $\fdot$}\end{verbatim} |
| 235 |
% Available options to \verb|\autopdfpsfrag| are: |
| 236 |
% \begin{description} |
| 237 |
% \item[texpos] The \LaTeX\ text reference point. Defaults to \verb|Bl|. |
| 238 |
% \item[epspos] The Postscript text reference point. Defaults to \verb|Bl|. |
| 239 |
% \item[scale] Scaling factor. Defaults to 1. |
| 240 |
% \item[angle] Extra text rotation, in degrees. Defaults to 0. |
| 241 |
% \item[add] If included, add the replacement text to any existing replacement text, |
| 242 |
% instead of replacing it (the default behaviour). |
| 243 |
% \end{description} |
| 244 |
% See the \textsf{PSfrag} manual for further details. |
| 245 |
% Default values of the \verb|\autopdfpsfrag| may be changed with the |
| 246 |
% \verb|\autopdfpsfoptions{options...}| command. |
| 247 |
% |
| 248 |
% \StopEventually{} |
| 249 |
% |
| 250 |
% \section{Implementation} |
| 251 |
% |
| 252 |
% \begin{macrocode} |
| 253 |
%<*package> |
| 254 |
% \end{macrocode} |
| 255 |
% Required packages. |
| 256 |
% \begin{macrocode} |
| 257 |
\RequirePackage{keyval} |
| 258 |
\RequirePackage{ifthen} |
| 259 |
\RequirePackage{ifpdf} |
| 260 |
\RequirePackage{ifplatform} |
| 261 |
\RequirePackage{graphicx} |
| 262 |
% \end{macrocode} |
| 263 |
% Check that we're running with pdf\LaTeX, and that \textsf{PSfrag} hasn't been included. |
| 264 |
% \begin{macrocode} |
| 265 |
\AtBeginDocument{% |
| 266 |
\ifthenelse{\NOT\boolean{pdf}}{% |
| 267 |
\PackageError{autopdf}{% |
| 268 |
This package is designed to work with pdfLaTeX. % |
| 269 |
Use "pdflatex" instead of "latex" to compile this document% |
| 270 |
}{}% |
| 271 |
}{% |
| 272 |
}% |
| 273 |
\@ifpackageloaded{psfrag}{% |
| 274 |
\PackageError{autopdf}{% |
| 275 |
This package is incompatible with the PSfrag package. % |
| 276 |
Do not \string\usepackage{psfrag} in this document% |
| 277 |
}{}% |
| 278 |
}{% |
| 279 |
}% |
| 280 |
} |
| 281 |
% \end{macrocode} |
| 282 |
% Global constants and variables. |
| 283 |
% \begin{macrocode} |
| 284 |
\begingroup |
| 285 |
\@makeother\% |
| 286 |
\xdef\autopdf@pc{%} |
| 287 |
\endgroup |
| 288 |
\def\autopdf@eol{^^J} |
| 289 |
\newwrite\autopdf@write |
| 290 |
\newlength\autopdf@width |
| 291 |
\newlength\autopdf@height |
| 292 |
\newcount\autopdf@width@dpi |
| 293 |
\newcount\autopdf@height@dpi |
| 294 |
\newtoks\autopdf@tex@toks |
| 295 |
% \end{macrocode} |
| 296 |
% Utility functions, mostly for manipulating \TeX\ token lists and text. |
| 297 |
% \begin{macrocode} |
| 298 |
\def\autopdf@If#1#2{\ifthenelse{#1}{#2}{}} |
| 299 |
\def\autopdf@IfElse#1#2#3{\ifthenelse{#1}{#2}{#3}} |
| 300 |
\def\autopdf@CatToks#1#2#3{% |
| 301 |
\toks@={#3}% |
| 302 |
\edef\autopdf@CatToks@a{% |
| 303 |
#1#2={\the#2\the\toks@}% |
| 304 |
}% |
| 305 |
\autopdf@CatToks@a% |
| 306 |
} |
| 307 |
\def\autopdf@ECatToks#1#2#3{% |
| 308 |
\edef\autopdf@ECatToks@a{% |
| 309 |
#1#2={\the#2#3}% |
| 310 |
}% |
| 311 |
\autopdf@ECatToks@a% |
| 312 |
} |
| 313 |
\def\autopdf@Split#1#2#3#4{% |
| 314 |
\@tempcnta#3% |
| 315 |
\edef\autopdf@Split@a{}% |
| 316 |
\edef\autopdf@Split@b{#4}% |
| 317 |
\autopdf@If{\NOT\equal{#4}{}}{% |
| 318 |
\expandafter\autopdf@@Split#4\@nil% |
| 319 |
}% |
| 320 |
\edef#1{\autopdf@Split@a}% |
| 321 |
\edef#2{\autopdf@Split@b}% |
| 322 |
}% |
| 323 |
\def\autopdf@@Split#1#2\@nil{% |
| 324 |
\autopdf@If{\@tempcnta>0}{% |
| 325 |
\edef\autopdf@Split@a{\autopdf@Split@a#1}% |
| 326 |
\edef\autopdf@Split@b{#2}% |
| 327 |
\advance\@tempcnta\m@ne% |
| 328 |
}% |
| 329 |
\autopdf@If{\NOT\equal{#2}{}}{% |
| 330 |
\expandafter\autopdf@@Split#2\@nil% |
| 331 |
}% |
| 332 |
} |
| 333 |
\def\autopdf@First#1#2#3{% |
| 334 |
\edef\autopdf@First@a{}% |
| 335 |
\autopdf@Split#1\autopdf@First@a#2#3% |
| 336 |
} |
| 337 |
\def\autopdf@Last#1#2#3{% |
| 338 |
\edef\autopdf@Last@a{}% |
| 339 |
\autopdf@Split\autopdf@Last@a#1#2#3% |
| 340 |
} |
| 341 |
\def\autopdf@BeforeDot#1.#2\@nil{#1} |
| 342 |
\def\autopdf@AfterDot#1.#2\@nil{#2} |
| 343 |
% \end{macrocode} |
| 344 |
% Functions which generate MD5 checksums, and read/write them to/from the log file. |
| 345 |
% \begin{macrocode} |
| 346 |
\def\autopdf@CreateMDF#1#2#3#4{% |
| 347 |
\autopdf@IfElse{\boolean{autopdf@scale}}{% |
| 348 |
\def\autopdf@scale@str{true}% |
| 349 |
}{% |
| 350 |
\def\autopdf@scale@str{false}% |
| 351 |
}% |
| 352 |
\expandafter\edef\expandafter#1{% |
| 353 |
\pdfmdfivesum{% |
| 354 |
from=#2,% |
| 355 |
to=#3,% |
| 356 |
scale=\autopdf@scale@str,% |
| 357 |
margin=\the\autopdf@margin,% |
| 358 |
resolution=\the\autopdf@resolution,% |
| 359 |
#4% |
| 360 |
}% |
| 361 |
}% |
| 362 |
} |
| 363 |
\def\autopdf@GetMDF#1{% |
| 364 |
\expandafter\ifcsname autopdf@mdflist@#1\endcsname% |
| 365 |
\expandafter\csname autopdf@mdflist@#1\endcsname% |
| 366 |
\else% |
| 367 |
\expandafter none% |
| 368 |
\fi% |
| 369 |
} |
| 370 |
\def\autopdf@SetMDF#1#2{% |
| 371 |
\expandafter\def\csname autopdf@mdflist@#1\endcsname{#2}% |
| 372 |
} |
| 373 |
% \end{macrocode} |
| 374 |
% Package options. |
| 375 |
% \begin{macrocode} |
| 376 |
\newboolean{autopdf@showcmds} |
| 377 |
\newboolean{autopdf@cleanup} |
| 378 |
\newboolean{autopdf@scale} |
| 379 |
\newlength\autopdf@margin |
| 380 |
\newcount\autopdf@resolution |
| 381 |
\define@key{autopdf}{from}{% |
| 382 |
\edef\autopdf@from@default{.\expandafter\autopdf@AfterDot .#1\@nil}% |
| 383 |
} |
| 384 |
\define@key{autopdf}{to}{% |
| 385 |
\edef\autopdf@to@default{.\expandafter\autopdf@AfterDot .#1\@nil}% |
| 386 |
} |
| 387 |
\define@key{autopdf}{logfile}{% |
| 388 |
\edef\autopdf@log@file{\jobname.#1}% |
| 389 |
} |
| 390 |
\define@key{autopdf}{nologfile}[]{% |
| 391 |
\edef\autopdf@log@file{}% |
| 392 |
} |
| 393 |
\define@key{autopdf}{showcmds}[true]{% |
| 394 |
\setboolean{autopdf@showcmds}{#1}% |
| 395 |
} |
| 396 |
\define@key{autopdf}{cleanup}[true]{% |
| 397 |
\setboolean{autopdf@cleanup}{#1}% |
| 398 |
} |
| 399 |
\define@key{autopdf}{scale}[true]{% |
| 400 |
\setboolean{autopdf@scale}{#1}% |
| 401 |
} |
| 402 |
\define@key{autopdf}{margin}{% |
| 403 |
\autopdf@margin=#1% |
| 404 |
} |
| 405 |
\define@key{autopdf}{resolution}{% |
| 406 |
\autopdf@resolution=#1% |
| 407 |
} |
| 408 |
\define@key{autopdf}{gscmd}{% |
| 409 |
\def\autopdf@GS{#1}% |
| 410 |
} |
| 411 |
\define@key{autopdf}{gmidentifycmd}{% |
| 412 |
\def\autopdf@GMIDENTIFY{#1}% |
| 413 |
} |
| 414 |
\define@key{autopdf}{gmconvertcmd}{% |
| 415 |
\def\autopdf@GMCONVERT{#1}% |
| 416 |
} |
| 417 |
\AtEndOfPackage{\let\@unprocessedoptions\relax} |
| 418 |
\def\autopdf@SetOptions#1{% |
| 419 |
\setkeys{autopdf}{#1}% |
| 420 |
} |
| 421 |
\autopdf@SetOptions{% |
| 422 |
from=eps,to=pdf,% |
| 423 |
logfile=autopdf_log,% |
| 424 |
showcmds=false,% |
| 425 |
cleanup=true,% |
| 426 |
scale=true,% |
| 427 |
margin=0pt,% |
| 428 |
resolution=600,% |
| 429 |
gmidentifycmd=gm~identify,% |
| 430 |
gmconvertcmd=gm~convert% |
| 431 |
} |
| 432 |
\autopdf@IfElse{\boolean{windows}}{% |
| 433 |
\autopdf@SetOptions{gscmd=gswin64c}% |
| 434 |
}{% |
| 435 |
\autopdf@SetOptions{gscmd=gs}% |
| 436 |
}% |
| 437 |
\edef\autopdf@a{% |
| 438 |
\noexpand\autopdf@SetOptions{\@ptionlist{\@currname.\@currext}}% |
| 439 |
} |
| 440 |
\autopdf@a |
| 441 |
\let\autopdfoptions\autopdf@SetOptions |
| 442 |
% \end{macrocode} |
| 443 |
% Read the log file at the start of processing, and |
| 444 |
% write to it at the end of the document. |
| 445 |
% \begin{macrocode} |
| 446 |
\autopdf@If{\NOT\equal{\autopdf@log@file}{}}{% |
| 447 |
\InputIfFileExists{\autopdf@log@file}{}{}% |
| 448 |
} |
| 449 |
\newtoks\autopdf@log@toks |
| 450 |
\autopdf@log@toks={} |
| 451 |
\def\autopdf@WriteLog#1{% |
| 452 |
\autopdf@ECatToks{\global}{\autopdf@log@toks}{#1}% |
| 453 |
} |
| 454 |
\AtEndDocument{% |
| 455 |
\autopdf@If{% |
| 456 |
\(\NOT\equal{\autopdf@log@file}{}\)\AND% |
| 457 |
\(\NOT\equal{\the\autopdf@log@toks}{}\)% |
| 458 |
}{% |
| 459 |
\immediate\openout\autopdf@write\autopdf@log@file\relax% |
| 460 |
\immediate\write\autopdf@write{\the\autopdf@log@toks}% |
| 461 |
\immediate\closeout\autopdf@write% |
| 462 |
}% |
| 463 |
} |
| 464 |
% \end{macrocode} |
| 465 |
% Function which executes external calls to graphics conversion programs. |
| 466 |
% \begin{macrocode} |
| 467 |
\def\autopdf@Execute@diva{================================} |
| 468 |
\def\autopdf@Execute@divb{ autopdf } |
| 469 |
\def\autopdf@Execute@divc{--------------------------------} |
| 470 |
\def\autopdf@Execute@divd{---------} |
| 471 |
\def\autopdf@Execute#1{% |
| 472 |
\begingroup% |
| 473 |
\let\\\relax% |
| 474 |
\def~{\space}% |
| 475 |
\def\AND{&&}% |
| 476 |
\def\OR{||}% |
| 477 |
\def\REDIRTO{>}% |
| 478 |
\def\LEFT{(}% |
| 479 |
\def\RIGHT{)}% |
| 480 |
\autopdf@IfElse{\boolean{windows}}{% |
| 481 |
\autopdf@IfElse{\boolean{autopdf@cleanup}}{% |
| 482 |
\def\DELETE{del~/f~/q}% |
| 483 |
}{% |
| 484 |
\def\DELETE{echo}% |
| 485 |
}% |
| 486 |
\def\SILENT{1>nul~2>&1}% |
| 487 |
}{% |
| 488 |
\autopdf@IfElse{\boolean{autopdf@cleanup}}{% |
| 489 |
\def\DELETE{rm~-f}% |
| 490 |
}{% |
| 491 |
\def\DELETE{echo}% |
| 492 |
}% |
| 493 |
\def\SILENT{1>/dev/null~2>&1}% |
| 494 |
}% |
| 495 |
\autopdf@IfElse{\boolean{autopdf@showcmds}}{% |
| 496 |
\immediate\write16{% |
| 497 |
^^J% |
| 498 |
\autopdf@Execute@diva% |
| 499 |
\autopdf@Execute@divb% |
| 500 |
\autopdf@Execute@diva% |
| 501 |
}% |
| 502 |
\immediate\write16{#1}% |
| 503 |
\immediate\write16{% |
| 504 |
\autopdf@Execute@divc% |
| 505 |
\autopdf@Execute@divd% |
| 506 |
\autopdf@Execute@divc% |
| 507 |
}% |
| 508 |
\immediate\write18{#1}% |
| 509 |
\immediate\write16{% |
| 510 |
\autopdf@Execute@divc% |
| 511 |
\autopdf@Execute@divb% |
| 512 |
\autopdf@Execute@divc% |
| 513 |
^^J% |
| 514 |
}% |
| 515 |
}{% |
| 516 |
\immediate\write18{\LEFT~#1~\RIGHT~\SILENT}% |
| 517 |
}% |
| 518 |
\endgroup% |
| 519 |
} |
| 520 |
% \end{macrocode} |
| 521 |
% The \verb|\autopdfinclude...\autopdfendinclude| command. |
| 522 |
% \begin{macrocode} |
| 523 |
\newcount\autopdf@Capture@list@count |
| 524 |
\autopdf@Capture@list@count=\z@ |
| 525 |
\def\autopdf@Capture#1{% |
| 526 |
\toks@={#1}% |
| 527 |
\edef\autopdf@a{\the\toks@}% |
| 528 |
\expandafter\edef\csname autopdf@Capture@list@% |
| 529 |
\the\autopdf@Capture@list@count\endcsname{% |
| 530 |
\expandafter\strip@prefix\meaning\autopdf@a% |
| 531 |
}% |
| 532 |
\advance\autopdf@Capture@list@count\@ne% |
| 533 |
#1% |
| 534 |
} |
| 535 |
\long\def\autopdfinclude#1\autopdfendinclude{% |
| 536 |
\autopdf@Capture{#1}% |
| 537 |
} |
| 538 |
% \end{macrocode} |
| 539 |
% The \verb|\autopdfpsfrag| and \verb|\autopdfpsfoptions| commands. |
| 540 |
% \begin{macrocode} |
| 541 |
\newboolean{autopdf@PSfrag@add} |
| 542 |
\define@key{autopdf@PSfrag}{texpos}{% |
| 543 |
\edef\autopdf@PSfrag@texpos{#1}% |
| 544 |
} |
| 545 |
\define@key{autopdf@PSfrag}{epspos}{% |
| 546 |
\edef\autopdf@PSfrag@epspos{#1}% |
| 547 |
} |
| 548 |
\define@key{autopdf@PSfrag}{scale}{% |
| 549 |
\edef\autopdf@PSfrag@scale{#1}% |
| 550 |
} |
| 551 |
\define@key{autopdf@PSfrag}{angle}{% |
| 552 |
\edef\autopdf@PSfrag@angle{#1}% |
| 553 |
} |
| 554 |
\define@key{autopdf@PSfrag}{add}[true]{% |
| 555 |
\setboolean{autopdf@PSfrag@add}{#1}% |
| 556 |
} |
| 557 |
\def\autopdf@SetPSfragOptions#1{% |
| 558 |
\setkeys{autopdf@PSfrag}{#1}% |
| 559 |
}% |
| 560 |
\autopdf@SetPSfragOptions{% |
| 561 |
texpos=Bl,epspos=Bl,% |
| 562 |
scale=1,angle=0,% |
| 563 |
} |
| 564 |
\def\autopdf@PSfrag{% |
| 565 |
\@ifnextchar[{% |
| 566 |
\autopdf@@PSfrag% |
| 567 |
}{% |
| 568 |
\autopdf@@PSfrag[]% |
| 569 |
}% |
| 570 |
} |
| 571 |
\def\autopdf@@PSfrag[#1]#2#3{% |
| 572 |
\begingroup% |
| 573 |
\setkeys{autopdf@PSfrag}{#1}% |
| 574 |
\def\autopdf@PSfrag@tag{#2}% |
| 575 |
\def\autopdf@PSfrag@tex{#3}% |
| 576 |
\xdef\autopdf@PSfrag@cmd{% |
| 577 |
\string\psfrag\ifautopdf@PSfrag@add*\fi% |
| 578 |
{\expandafter\strip@prefix\meaning\autopdf@PSfrag@tag}% |
| 579 |
[\autopdf@PSfrag@texpos][\autopdf@PSfrag@epspos]% |
| 580 |
[\autopdf@PSfrag@scale][\autopdf@PSfrag@angle]% |
| 581 |
{\expandafter\strip@prefix\meaning\autopdf@PSfrag@tex}% |
| 582 |
}% |
| 583 |
\endgroup% |
| 584 |
\expandafter\let\csname autopdf@Capture@list@% |
| 585 |
\the\autopdf@Capture@list@count\endcsname\autopdf@PSfrag@cmd% |
| 586 |
\advance\autopdf@Capture@list@count\@ne% |
| 587 |
} |
| 588 |
\let\autopdfpsfrag\autopdf@PSfrag |
| 589 |
\let\autopdfpsfoptions\autopdf@SetPSfragOptions |
| 590 |
% \end{macrocode} |
| 591 |
% Get the types of graphics files from their extensions, or use the defaults. |
| 592 |
% \begin{macrocode} |
| 593 |
\def\autopdf@GetGrType#1#2{% |
| 594 |
\@ifundefined{Gin@rule@#2}{% |
| 595 |
\edef#1{\expandafter\autopdf@AfterDot #2\@nil}% |
| 596 |
}{% |
| 597 |
\def\autopdf@GetGrType@a{% |
| 598 |
\edef#1{% |
| 599 |
\expandafter\expandafter\expandafter% |
| 600 |
\autopdf@@GetGrType\csname Gin@rule@#2\endcsname{}% |
| 601 |
}% |
| 602 |
}% |
| 603 |
\autopdf@GetGrType@a% |
| 604 |
}% |
| 605 |
} |
| 606 |
\def\autopdf@@GetGrType#1#2#3{% |
| 607 |
#1% |
| 608 |
} |
| 609 |
% \end{macrocode} |
| 610 |
% Determine the size of a graphic, either from \textsf{graphicx} (for EPS files) |
| 611 |
% or by running the GraphicsMagick \verb|identify| command (for other formats). |
| 612 |
% \begin{macrocode} |
| 613 |
\def\autopdf@ReadGrSize#1#2{% |
| 614 |
\begingroup% |
| 615 |
\ifGin@bbox% |
| 616 |
\else% |
| 617 |
\autopdf@GetGrType\autopdf@type{#2}% |
| 618 |
\autopdf@Execute{% |
| 619 |
\autopdf@GMIDENTIFY~% |
| 620 |
-units~PixelsPerInch~% |
| 621 |
-format~"% |
| 622 |
\\\\def\\\\width{\autopdf@pc[fx:w/image.resolution.x*72]}% |
| 623 |
\\\\def\\\\height{\autopdf@pc[fx:h/image.resolution.y*72]}% |
| 624 |
"~% |
| 625 |
#1#2~\REDIRTO~#1.size~% |
| 626 |
\OR~\DELETE~#1.size~% |
| 627 |
}% |
| 628 |
\IfFileExists{#1.size}{% |
| 629 |
\def\Gin@llx{0}\def\Gin@lly{0}% |
| 630 |
\begingroup% |
| 631 |
\input{#1.size}% |
| 632 |
\edef\autopdf@a{% |
| 633 |
\def\noexpand\Gin@urx{\width}% |
| 634 |
\def\noexpand\Gin@ury{\height}% |
| 635 |
}% |
| 636 |
\expandafter% |
| 637 |
\endgroup\autopdf@a% |
| 638 |
\autopdf@Execute{\DELETE~#1.size}% |
| 639 |
}{% |
| 640 |
\PackageError{autopdf}{% |
| 641 |
Could not determine size of "#1#2"% |
| 642 |
}{}% |
| 643 |
}% |
| 644 |
\fi% |
| 645 |
\Gin@viewport@code% |
| 646 |
\Gin@nat@width=\Gin@urx bp% |
| 647 |
\advance\Gin@nat@width-\Gin@llx bp% |
| 648 |
\Gin@nat@height=\Gin@ury bp% |
| 649 |
\advance\Gin@nat@height-\Gin@lly bp% |
| 650 |
\Gin@req@sizes% |
| 651 |
\autopdf@IfElse{\boolean{autopdf@scale}}{% |
| 652 |
\global\autopdf@width=\Gin@req@width% |
| 653 |
\global\autopdf@height=\Gin@req@height% |
| 654 |
}{% |
| 655 |
\global\autopdf@width=\Gin@nat@width% |
| 656 |
\global\autopdf@height=\Gin@nat@height% |
| 657 |
}% |
| 658 |
\global\autopdf@width@dpi=\expandafter% |
| 659 |
\autopdf@BeforeDot\the\autopdf@width\@nil% |
| 660 |
\global\autopdf@height@dpi=\expandafter% |
| 661 |
\autopdf@BeforeDot\the\autopdf@height\@nil% |
| 662 |
\global\multiply\autopdf@width@dpi by \autopdf@resolution% |
| 663 |
\global\multiply\autopdf@height@dpi by \autopdf@resolution% |
| 664 |
\global\divide\autopdf@width@dpi by 72% |
| 665 |
\global\divide\autopdf@height@dpi by 72% |
| 666 |
\endgroup% |
| 667 |
} |
| 668 |
% \end{macrocode} |
| 669 |
% Replace the internal \textsf{graphicx} command \verb|\Ginclude@graphics| with |
| 670 |
% a new version, which performs any required graphics conversions before inclusion. |
| 671 |
% \begin{macrocode} |
| 672 |
\def\autopdf@IncludeGraphics#1{% |
| 673 |
\edef\autopdf@to{}% |
| 674 |
\begingroup% |
| 675 |
\let\to\relax% |
| 676 |
\expandafter% |
| 677 |
\endgroup% |
| 678 |
\autopdf@@IncludeGraphics#1\to\to\@nil% |
| 679 |
} |
| 680 |
\def\autopdf@@IncludeGraphics#1\to#2\to#3\@nil{% |
| 681 |
\edef\autopdf@to{#2}% |
| 682 |
\begingroup% |
| 683 |
\let\input@path\Ginput@path% |
| 684 |
\filename@parse{#1}% |
| 685 |
\edef\autopdf@dir{\filename@area}% |
| 686 |
\autopdf@If{\equal{\autopdf@dir}{}}{% |
| 687 |
\edef\autopdf@dir{\@currdir}% |
| 688 |
}% |
| 689 |
\ifx\filename@ext\relax% |
| 690 |
\edef\autopdf@from{\autopdf@from@default}% |
| 691 |
\else% |
| 692 |
\edef\autopdf@from{\Gin@sepdefault\filename@ext}% |
| 693 |
\fi% |
| 694 |
\Gin@getbase{\autopdf@from}% |
| 695 |
\ifx\Gin@ext\relax% |
| 696 |
\PackageError{autopdf}{% |
| 697 |
File "#1\autopdf@from" could not be found% |
| 698 |
}{}% |
| 699 |
\else% |
| 700 |
\edef\autopdf@base{\Gin@base}% |
| 701 |
\autopdf@If{\equal{\autopdf@to}{}}{% |
| 702 |
\edef\autopdf@to{\autopdf@to@default}% |
| 703 |
}% |
| 704 |
\let\autopdf@Gin@setfile\relax% |
| 705 |
\@ifundefined{Gin@rule@\autopdf@to}{% |
| 706 |
\@ifundefined{Gin@rule@*}{% |
| 707 |
\PackageError{autopdf}{% |
| 708 |
Graphics extension "\autopdf@to" is not supported% |
| 709 |
}{}% |
| 710 |
}{% |
| 711 |
\def\autopdf@Gin@setfile{% |
| 712 |
\expandafter\expandafter\expandafter\Gin@setfile% |
| 713 |
\csname Gin@rule@*\endcsname{\autopdf@base\autopdf@to}% |
| 714 |
}% |
| 715 |
}% |
| 716 |
}{% |
| 717 |
\def\autopdf@Gin@setfile{% |
| 718 |
\expandafter\expandafter\expandafter\Gin@setfile% |
| 719 |
\csname Gin@rule@\autopdf@to\endcsname{% |
| 720 |
\autopdf@base\autopdf@to% |
| 721 |
}% |
| 722 |
}% |
| 723 |
}% |
| 724 |
\autopdf@ConvertGraphics{\autopdf@from}{\autopdf@to}% |
| 725 |
\IfFileExists{\autopdf@base\autopdf@to}{% |
| 726 |
}{% |
| 727 |
\PackageError{autopdf}{% |
| 728 |
Could not convert % |
| 729 |
"\autopdf@base\autopdf@mid" to "\autopdf@base#2". % |
| 730 |
See "\[email protected]" for details% |
| 731 |
}{}% |
| 732 |
}% |
| 733 |
\autopdf@Gin@setfile% |
| 734 |
\fi% |
| 735 |
\endgroup% |
| 736 |
} |
| 737 |
\let\Ginclude@graphics\autopdf@IncludeGraphics |
| 738 |
% \end{macrocode} |
| 739 |
% Perform the graphics conversions. For (\LaTeX/)EPS or PostScript graphics, |
| 740 |
% generates the wrapper \LaTeX\ file and coverts to PostScript, then calls |
| 741 |
% either Ghostscript (PS to PDF) or GraphicsMagick (other combinations) to |
| 742 |
% convert to the final output format. |
| 743 |
% For other graphics formats, call GraphicsMagick only. |
| 744 |
% \begin{macrocode} |
| 745 |
\def\autopdf@ConvertGraphics#1#2{% |
| 746 |
\autopdf@If{\NOT\equal{#1}{#2}}{% |
| 747 |
\autopdf@WriteLog{% |
| 748 |
\autopdf@pc in \autopdf@base#1\autopdf@eol% |
| 749 |
}% |
| 750 |
\autopdf@GetGrType\autopdf@from@type{#1}% |
| 751 |
\autopdf@GetGrType\autopdf@to@type{#2}% |
| 752 |
\autopdf@IfElse{\equal{\autopdf@from@type}{eps}}{% |
| 753 |
\autopdf@ReadGrSize{\autopdf@base}{#1}% |
| 754 |
\autopdf@EPSToPSTeX{#1}% |
| 755 |
\autopdf@CreateMDF\autopdf@Graphics@mdfa{#1}{#2}{% |
| 756 |
\pdfmdfivesum{\the\autopdf@tex@toks}% |
| 757 |
}% |
| 758 |
}{% |
| 759 |
\autopdf@IfElse{\equal{\autopdf@from@type}{tex}}{% |
| 760 |
\newboolean{autopdf@scale@old}% |
| 761 |
\autopdf@IfElse{\boolean{autopdf@scale}}{% |
| 762 |
\setboolean{autopdf@scale@old}{true}% |
| 763 |
}{% |
| 764 |
\setboolean{autopdf@scale@old}{false}% |
| 765 |
}% |
| 766 |
\setboolean{autopdf@scale}{false}% |
| 767 |
\autopdf@ReadGrSize{\autopdf@base}{.eps}% |
| 768 |
\autopdf@EPSToPSTeX{#1}% |
| 769 |
\autopdf@CreateMDF\autopdf@Graphics@mdfa{#1}{#2}{% |
| 770 |
\pdfmdfivesum file{\[email protected]}% |
| 771 |
\pdfmdfivesum file{\[email protected]}% |
| 772 |
\pdfmdfivesum{\the\autopdf@tex@toks}% |
| 773 |
}% |
| 774 |
\autopdf@IfElse{\boolean{autopdf@scale@old}}{% |
| 775 |
\setboolean{autopdf@scale}{true}% |
| 776 |
}{% |
| 777 |
\setboolean{autopdf@scale}{false}% |
| 778 |
}% |
| 779 |
}{% |
| 780 |
\autopdf@CreateMDF\autopdf@Graphics@mdfa{#1}{#2}{% |
| 781 |
\pdfmdfivesum file{\autopdf@base#1}% |
| 782 |
}% |
| 783 |
}% |
| 784 |
}% |
| 785 |
\edef\autopdf@Graphics@mdfb{\autopdf@GetMDF{\autopdf@base#1}}% |
| 786 |
\IfFileExists{\autopdf@base#2}{% |
| 787 |
}{% |
| 788 |
\edef\autopdf@Graphics@mdfb{rebuild}% |
| 789 |
}% |
| 790 |
\autopdf@If{\NOT\(% |
| 791 |
\pdfstrcmp{\autopdf@Graphics@mdfa}{\autopdf@Graphics@mdfb}=0% |
| 792 |
\)}{% |
| 793 |
\autopdf@If{\NOT\(\pdfshellescape=1\)}{% |
| 794 |
\PackageError{autopdf}{% |
| 795 |
This package requires pdfLaTeX to % |
| 796 |
be running in "shell escape" mode% |
| 797 |
}{}% |
| 798 |
}% |
| 799 |
\autopdf@IfElse{% |
| 800 |
\equal{\autopdf@from@type}{eps}% |
| 801 |
\OR\equal{\autopdf@from@type}{tex}% |
| 802 |
}{% |
| 803 |
\autopdf@EPSToPS% |
| 804 |
\IfFileExists{\[email protected]}{% |
| 805 |
}{% |
| 806 |
\PackageError{autopdf}{% |
| 807 |
Could not convert % |
| 808 |
"\autopdf@base#1" to "\[email protected]". % |
| 809 |
See "\[email protected]" for details% |
| 810 |
}{}% |
| 811 |
}% |
| 812 |
\def\autopdf@mid{.ps}% |
| 813 |
}{% |
| 814 |
\autopdf@ReadGrSize{\autopdf@base}{#1}% |
| 815 |
\def\autopdf@mid{#1}% |
| 816 |
}% |
| 817 |
\autopdf@If{\NOT\equal{\autopdf@mid}{#2}}{% |
| 818 |
\autopdf@IfElse{\equal{\autopdf@mid}{.ps}\AND\equal{#2}{.pdf}}{% |
| 819 |
\autopdf@PSToPDF% |
| 820 |
}{% |
| 821 |
\autopdf@Convert{\autopdf@mid}{#2}% |
| 822 |
}% |
| 823 |
}% |
| 824 |
\IfFileExists{\autopdf@base#2}{% |
| 825 |
\autopdf@If{% |
| 826 |
\NOT\(\equal{\autopdf@mid}{#1}\OR\equal{\autopdf@mid}{#2}\)% |
| 827 |
}{% |
| 828 |
\autopdf@Execute{\DELETE~\autopdf@base\autopdf@mid}% |
| 829 |
}% |
| 830 |
}{% |
| 831 |
\PackageError{autopdf}{% |
| 832 |
Could not convert % |
| 833 |
"\autopdf@base\autopdf@mid" to "\autopdf@base#2". % |
| 834 |
See "\[email protected]" for details% |
| 835 |
}{}% |
| 836 |
}% |
| 837 |
}% |
| 838 |
\autopdf@WriteLog{% |
| 839 |
\string\autopdf@SetMDF{\autopdf@base#1}% |
| 840 |
{\autopdf@Graphics@mdfa}\autopdf@eol% |
| 841 |
\autopdf@pc out \autopdf@base#2\autopdf@eol% |
| 842 |
}% |
| 843 |
}% |
| 844 |
} |
| 845 |
% \end{macrocode} |
| 846 |
% Generates the wrapper \LaTeX\ file for (\LaTeX/)EPS or PostScript graphics. |
| 847 |
% \begin{macrocode} |
| 848 |
\def\autopdf@EPSToPSTeX#1{% |
| 849 |
\begingroup% |
| 850 |
\global\autopdf@tex@toks={}% |
| 851 |
\autopdf@ECatToks{\global}{\autopdf@tex@toks}{% |
| 852 |
\string\documentclass{minimal}\autopdf@eol% |
| 853 |
\string\usepackage[% |
| 854 |
paperwidth=\the\autopdf@width,% |
| 855 |
paperheight=\the\autopdf@height,% |
| 856 |
margin=\the\autopdf@margin,% |
| 857 |
offset=0pt,% |
| 858 |
bindingoffset=0pt,% |
| 859 |
noheadfoot,% |
| 860 |
nomarginpar% |
| 861 |
]{geometry}\autopdf@eol% |
| 862 |
\string\usepackage{graphicx}\autopdf@eol% |
| 863 |
\string\usepackage{psfrag}\autopdf@eol% |
| 864 |
\string\pagestyle{empty}\autopdf@eol% |
| 865 |
\string\setlength{\string\parindent}{0pt}\autopdf@eol% |
| 866 |
\string\setlength{\string\parskip}{0pt}\autopdf@eol% |
| 867 |
}% |
| 868 |
\def\autopdf@fonts{% |
| 869 |
\tiny,\scriptsize,\footnotesize,\small,% |
| 870 |
\normalsize,\large,\Large,\LARGE,\huge,\Huge% |
| 871 |
}% |
| 872 |
\@for\autopdf@a:=\autopdf@fonts\do{% |
| 873 |
\begingroup% |
| 874 |
\autopdf@a% |
| 875 |
\autopdf@ECatToks{\global}{\autopdf@tex@toks}{% |
| 876 |
\string\def\expandafter\string\autopdf@a{% |
| 877 |
\string\fontencoding{\f@encoding}% |
| 878 |
\string\fontfamily{\f@family}% |
| 879 |
\string\fontseries{\f@series}% |
| 880 |
\string\fontshape{\f@shape}% |
| 881 |
\string\fontsize{\f@size}{\f@baselineskip}% |
| 882 |
\string\selectfont% |
| 883 |
}\autopdf@eol% |
| 884 |
}% |
| 885 |
\endgroup% |
| 886 |
}% |
| 887 |
\autopdf@ECatToks{\global}{\autopdf@tex@toks}{% |
| 888 |
\string\normalsize\autopdf@eol% |
| 889 |
\string\makeatletter\autopdf@eol% |
| 890 |
}% |
| 891 |
\count@=\z@% |
| 892 |
\loop\ifnum\count@<\autopdf@Capture@list@count\relax% |
| 893 |
\autopdf@ECatToks{\global}{\autopdf@tex@toks}{% |
| 894 |
\string\def\string\autopdf@act{% |
| 895 |
\csname autopdf@Capture@list@\the\count@\endcsname% |
| 896 |
}% |
| 897 |
\string\autopdf@act\autopdf@eol% |
| 898 |
}% |
| 899 |
\advance\count@\@ne% |
| 900 |
\repeat% |
| 901 |
\autopdf@ECatToks{\global}{\autopdf@tex@toks}{% |
| 902 |
\string\def\string\autopdf@act{}\autopdf@eol% |
| 903 |
\string\makeatother\autopdf@eol% |
| 904 |
\string\begin{document}\autopdf@eol% |
| 905 |
}% |
| 906 |
\autopdf@IfElse{\equal{#1}{.tex}}{% |
| 907 |
\autopdf@ECatToks{\global}{\autopdf@tex@toks}{% |
| 908 |
\string\input{\autopdf@base#1}% |
| 909 |
}% |
| 910 |
}{% |
| 911 |
\autopdf@ECatToks{\global}{\autopdf@tex@toks}{% |
| 912 |
\string\includegraphics[% |
| 913 |
width=0.99\string\textwidth,height=0.99\string\textheight% |
| 914 |
]{\autopdf@base#1}% |
| 915 |
}% |
| 916 |
}% |
| 917 |
\autopdf@ECatToks{\global}{\autopdf@tex@toks}{% |
| 918 |
\autopdf@pc\pdfmdfivesum file{\autopdf@base#1}\autopdf@eol% |
| 919 |
\string\end{document}% |
| 920 |
}% |
| 921 |
\endgroup% |
| 922 |
} |
| 923 |
% \end{macrocode} |
| 924 |
% Calls \verb|latex| and \verb|dvips| to convert (\LaTeX/)EPS graphics to PostScript. |
| 925 |
% \begin{macrocode} |
| 926 |
\def\autopdf@EPSToPS{% |
| 927 |
\immediate\openout\autopdf@write \[email protected]\relax% |
| 928 |
\immediate\write\autopdf@write{\the\autopdf@tex@toks}% |
| 929 |
\immediate\closeout\autopdf@write% |
| 930 |
\autopdf@Execute{% |
| 931 |
\LEFT~% |
| 932 |
latex~% |
| 933 |
-interaction=nonstopmode~% |
| 934 |
-output-format=dvi~% |
| 935 |
-aux-directory=\autopdf@dir~% |
| 936 |
-output-directory=\autopdf@dir~% |
| 937 |
\[email protected]~% |
| 938 |
\AND~% |
| 939 |
dvips~% |
| 940 |
-o~\[email protected]~% |
| 941 |
\[email protected]~% |
| 942 |
\AND~% |
| 943 |
\DELETE~% |
| 944 |
\[email protected]~\[email protected]~% |
| 945 |
\[email protected]~\[email protected]~% |
| 946 |
\RIGHT~% |
| 947 |
\OR~% |
| 948 |
\DELETE~\[email protected]% |
| 949 |
}% |
| 950 |
} |
| 951 |
% \end{macrocode} |
| 952 |
% Calls Ghostscript to convert PostScript graphics to PDF. |
| 953 |
% \begin{macrocode} |
| 954 |
\def\autopdf@PSToPDF{% |
| 955 |
\autopdf@Execute{% |
| 956 |
\autopdf@GS~% |
| 957 |
-dSAFER~-dBATCH~-dNOPAUSE~-q~% |
| 958 |
-sDEVICE=pdfwrite~-dCompatibilityLevel=1.4~% |
| 959 |
-dAutoRotatePages="/None"~% |
| 960 |
-sOutputFile=\[email protected]~% |
| 961 |
-c~.setpdfwrite~-f~\[email protected]~% |
| 962 |
\OR~% |
| 963 |
\DELETE~\[email protected]~% |
| 964 |
}% |
| 965 |
} |
| 966 |
% \end{macrocode} |
| 967 |
% Calls the GraphicsMagick \verb|convert| command. |
| 968 |
% \begin{macrocode} |
| 969 |
\def\autopdf@Convert#1#2{% |
| 970 |
\autopdf@Execute{% |
| 971 |
\LEFT~% |
| 972 |
\autopdf@GMCONVERT~% |
| 973 |
-units~PixelsPerInch~% |
| 974 |
-density~\the\autopdf@resolution~% |
| 975 |
\autopdf@base#1~% |
| 976 |
-resize~\the\autopdf@width@dpi x\the\autopdf@height@dpi~% |
| 977 |
\autopdf@base#2~% |
| 978 |
\AND~% |
| 979 |
identify~\autopdf@base#2~% |
| 980 |
\RIGHT~% |
| 981 |
\OR~% |
| 982 |
\DELETE~\autopdf@base#2~% |
| 983 |
}% |
| 984 |
} |
| 985 |
%</package> |
| 986 |
% \end{macrocode} |
| 987 |
% |
| 988 |
% \Finale |
| 989 |
% |
| 990 |
\endinput |
| 991 |
|
| 992 |
%%% Local Variables: |
| 993 |
%%% mode: TeX |
| 994 |
%%% mode: TeX-PDF |
| 995 |
%%% End: |