[pdftex] epstopdf on the fly with graphics package
Heiko Oberdiek
oberdiek at ruf.uni-freiburg.de
Sat Jan 6 22:04:40 CET 2001
Hello,
the graphic{s,x} package knows the feature that
a command can be used in the fourth argument of
\DeclareGraphicsRule. The command is passed to
dvips that then calls it to get a image in a
format understandable by dvips, eg:
\DeclareGraphicsRule{ps.gz}{eps}{ps.bb}{`gunzip #1}
I have not seen, that this works with pdfTeX or
that a similar solution exists. But this is
possible, because pdfTeX does know the \write18
feature.
Therefore I have written a patch to get the
\DeclareGraphicsRule syntax work and have put
the stuff for testing in a package to be
loaded after graphic{s,x}.
Comments are welcome.
It is possible to detect within TeX, whether
the \write18 is enabled? (If so, an understandable
warning could be written, if \write18 is disabled.)
Best regards
Heiko <oberdiek at ruf.uni-freiburg.de>
%%% cut %%% epstopdf.sty %%% cut %%%
% File: epstopdf.sty
% Version: 2001/01/06 v1.0
% Author: Heiko Oberdiek
% Email: <oberdiek at ruf.uni-freiburg.de>
%
% Copyright: Copyright (C) 2001 Heiko Oberdiek.
%
% This program may be distributed and/or modified under
% the conditions of the LaTeX Project Public License,
% either version 1.2 of this license or (at your option)
% any later version. The latest version of this license
% is in
% http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions
% of LaTeX version 1999/12/01 or later.
%
% Function: This packages adds support of handling eps images
% to package graphic{s,x} with option `pdftex'.
% If an eps image is detected, epstopdf is called
% to convert it to pdf format.
%
% Required: * The program `epstopdf'.
% * The feature `\write18' has to be enabled to get
% the conversion via the program epstopdf work:
% * command line option: -shell-escape
% * configuraton file `texmf.cnf': shell_escape = 1
%
% Use: The package is loaded after graphic{s,x}, eg:
% \usepackage[pdftex]{graphicx}
% \usepackage{epstopdf}
% Images with extension `.eps' are now detected
% and supported:
% * Implicitly: \includegraphics{bild}
% If `bild.eps' can only be found,
% then it is converted to the file `bild.pdf',
% that will be used by pdfTeX.
% On the next ocurrences or on the next pdfTeX run,
% the pdf file is already available, so the
% conversion step is skipped.
% * Explicitly: \includegraphics{bild.eps}
% Each time the conversion program is called.
%
% History: 2001/01/06 v1.0:
% first public version, published in the pdftex
% mailing list.
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{epstopdf}[2001/01/06 v1.0 epstopdf on the fly (HO)]
% Check, whether package graphics is loaded
% (also graphicx loads graphics)
\@ifpackageloaded{graphics}{}{%
\PackageWarningNoLine{epstopdf}{%
No graphics package \string`graphic{s,x}\string' loaded%
}%
\endinput
}
% Check, whether pdftex.def is loaded
\@ifundefined{ver at pdftex.def}{%
\PackageWarningNoLine{epstopdf}{%
Graphics driver file \string`pdftex.def\string' not loaded%
}
\endinput
}
% Patch \Gin at setfile to execute #3, if it contains
% a command
\let\orgGin at setfile\Gin at setfile
\def\Gin at setfile#1#2#3{%
\if`\@car #3\relax\@nil
\immediate\write18{\@cdr #3\@empty\@nil}%
\orgGin at setfile{#1}{#2}{\Gin at base #2}%
\else
\orgGin at setfile{#1}{#2}{#3}%
\fi
}
% Adding .eps at the end of the list of extensions,
% defined by \DeclareGraphicsExtensions
\g at addto@macro\Gin at extensions{,.eps}
% \DeclareGraphicsRule for .eps
\@namedef{Gin at rule@.eps}#1{{pdf}{.pdf}{`epstopdf #1}}
\endinput
%%% cut %%% epsotpdf.sty %%% cut %%%
More information about the pdftex
mailing list