Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

As I understand it, embedding (as metadata) the typesetting engine that was used to produce a PDF document is good practice. Here is an example of how this can be done using the hyperref package:

\hypersetup{pdfcreator={pdflatex 1.40.14}}

However, hardcoding this information is error-prone. What if, between now and the final version of my document, I decide to switch typesetting engine, or what if a new version gets released, and I forget to update the metadata?

If possible, I'd like to avoid hardcoding the typesetting engine (name and version) used... Is there an easy way of accessing that information during a run of that engine on my tex file?

share|improve this question
1  
Related: tex.stackexchange.com/questions/26178/… –  cslstr May 6 at 19:58
    
In fact, \pdftexbanner may solve your whole problem...? Though it is a bit more verbose than desired, perhaps. –  cslstr May 6 at 20:00
    
@cslstr Thanks; the question (and its answers) you link to is interesting. It doesn't completely answer my question, though. I'd like to format the string as in my example. –  Jubobs May 6 at 20:13
    
@Jubobs: pdflatex is a mixup of pdfTeX and LaTeX, both have version numbers, e.g. 1.40.15 and 2014/05/01. –  Heiko Oberdiek May 6 at 20:15
add comment

2 Answers 2

up vote 9 down vote accepted

pdfTeX

The TeX compiler pdfTeX already sets some keys as default:

/Producer (pdfTeX-1.40.15)
/Creator (TeX)
/CreationDate (D:20140506215840+02'00')
/ModDate (D:20140506215840+02'00')
/Trapped /False
/PTEX.Fullbanner (This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) kpathsea version 6.2.0)

Some of these entries can be overwritten via \pdfinfo or via \hypersetup if hyperref is loaded. A nice feature of pdfTeX is, that if it detects the setting of standard keys in \pdfinfo, then pdfTeX suppresses its setting to avoid duplicate keys in the same dictionary with different values. Therefore it is possible for the user or hyperref to override the setting of pdfTeX.

The default of hyperref's values are (line breaks added for better readability):

/Author()
/Title()
/Subject()
/Creator(LaTeX with hyperref package)
/Producer(pdfTeX-1.40.15)
/Keywords()

Also the other entries can be set by hyperref (pdfcreationdate, pdfmoddate, ...)

Version number of pdfTeX

Since the version number scheme of pdfTeX has changed in the past, the algorithm for the versions specification is quite complex, from hpdftex.def:

\def\@pdfproducer{pdfTeX}%
\ifx\eTeXversion\@undefined
\else
  \ifx\eTeXversion\relax
  \else
    \ifnum\eTeXversion>0 %
      \def\@pdfproducer{pdfeTeX}%
    \fi
  \fi
\fi
\ifx\pdftexversion\@undefined
\else
  \ifnum\pdftexversion<100 %
    \edef\@pdfproducer{%
      \@pdfproducer
      \the\pdftexversion.\pdftexrevision
    }%
  \else
    \ifnum\pdftexversion<130 %
      \edef\@pdfproducer{%
        \@pdfproducer-%
        \expandafter\@car\the\pdftexversion\@empty\@nil.%
        \expandafter\@cdr\the\pdftexversion\@empty\@nil
        \pdftexrevision
      }%
    \else
      \ifnum\pdftexversion<140 %
      \else
        \def\@pdfproducer{pdfTeX}%
      \fi
      \edef\@pdfproducer{%
        \@pdfproducer-%
        \expandafter\@car\the\pdftexversion\@empty\@nil.%
        \expandafter\@cdr\the\pdftexversion\@empty\@nil.%
        \pdftexrevision
      }%
    \fi
  \fi
\fi

Other drivers

Package hyperref also sets information entries with the other drives. But it can happen, that the driver insists of its setting for some of the keys (/Creator, ...).

share|improve this answer
    
Aaah... thanks for that. So far, I had always hardcoded this info using \hypersetup; I hadn't realised pdfTeX already fills the relevant fields exactly as desired. Thanks again. –  Jubobs May 6 at 20:32
add comment

\pdftexbanner (introduced in pdfTeX 1.20a; see the pdfTeX user manual) looks like this:

This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/W32TeX) kpathsea version 6.1.1

and countains the version of pdfTeX. You can extract this using the following:

\makeatletter
\def\extractpdftexversion#1-#2-#3 #4\@nil{#3}
\edef\pdftexversion{\expandafter\extractpdftexversion\pdftexbanner\@nil}
\makeatother

Here \extractpdftexversion expects an argument text of the form <stuffA>-<stuffB>-<stuffC> <stuffD>\@nil, and only returns <stuffC> (that is, something delimited on the left by - and on the right by a space ). You can add it to your PDF document properties using

\pdfinfo{
  /Producer (pdfTeX \pdftexversion)
}

enter image description here

\documentclass{article}
\makeatletter
\def\extractpdftexversion#1-#2-#3 #4\@nil{#3}
\edef\pdftexversion{\expandafter\extractpdftexversion\pdftexbanner\@nil}
\makeatother
\pdfinfo{
  /Producer (pdfTeX \pdftexversion)
}
\begin{document}
\pdftexbanner
\end{document}

No explicit need to using hyperref (see Is hyperref really the best way to add metadata to a TeX file?).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.