Adding PDF metadata in LaTeX

When working on a LaTeX project of some value, you might want to add your credentials to the PDF metadata. This way, readers of the document will know who made the document and what its about without actually opening the document. Adding metadata might also be a good idea for copyright reasons, etc. As always, there are multiple ways of adding the data to documents. In this post I’ll explain the way I do it (and it isn’t difficult at all!).

The pdfinfo command

We will be using the pdfinfo command for adding the metadata. This command comes with pdfTeX. Using it is daily easy; all the metadata is put inside the argument of this command. Let’s show this with an example:

\pdfinfo{
   /Author (Author Name)
   /Title (Adding PDF metadata in LaTeX)
   /Keywords (PDF;LaTeX;howtoTeX.com)
}

In this example, an author tag, title tag and keywords are added to the PDF metadata when the LaTeX document is compiled. Note that the fields always start with a slash (/)

The metadata fields

The available fields to put inside the pdfinfo command are the following:

  • /Title: title of the document
  • /Author: author of the document
  • /Creator: PDF creator
  • /Producer: PDF producer
  • /CreationDate: creation date
  • /ModDate: modification date
  • /Subject: subject of the document
  • /Keywords: keywords, separated by a semicolon (;)

One note about the time fields. These should be in the format D:YYYYMMDDHHmmss (so the actual date is preceded by D:). For example:

\pdfinfo{
      /CreationDate (D:20120501205500)
}

This way, the creation date will be May 1, 2012 at 20:55:00h. This seems rather cumbersome, so let’s give an alternative using the datetime. This package introduces the \pdfdate command which also can be used: For example:

\usepackage{datetime}
\pdfinfo{
      /CreationDate (D:\pdfdate)
}

Possible errors

The pdfinfo command comes with pdfTeX or pdfLaTeX, meaning that it will not work when a document is compiled with something else that pdfTeX/pdfLaTeX. On this site a nice error check is found, by making use of the ifpdf package:

\usepackage{ifpdf}
\ifpdf
\pdfinfo{
   /Author (Author Name)
   /Title (Adding PDF metadata in LaTeX)
   /Keywords (PDF;LaTeX;howtoTeX.com)
}
\fi

In words, this piece of code only reads the pdfinfo command if the document is compiled to PDF format (with pdfTeX/pdfLaTeX).

Alternatives

An alternative way would be to use the hyperref package (which is one of the essential LaTeX package I posted about). The necessary commands are described in section 3.6 of its documentation.

6 Comments

  1. I’d like to find out more? I’d like to find out more details.

  2. football says:

    He’s not desperately trying to look like a big shot. Most online football managers give
    you a team when you sign up and you’re stuck with them forever, no matter how well
    you do. Among those that came out in the wish list
    is a better line play, addition of team entrances,
    and crowd atmosphere.

  3. Majid says:

    Will this work with xelatex? how about lualatex? both these engines’ output is pdf.

  4. mankoff says:

    Is there a difference between this and using hyperref to add PDF meta-data?

Leave a Reply




XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>