106

I am writing a document using LaTeX and generating PDF. Can anybody tell me how I can generate the PDF metadata, e.g. author or title, from LaTeX? On Windows XP, I am using MikTex's texify to generate the PDF. On linux, I am using pdflatex to generate the PDF. Any answers for either platform would be much appreciated!

migrated from stackoverflow.com Aug 25 '11 at 17:06

This question came from our site for professional and enthusiast programmers.

136

Use the hyperref package, included in pretty much every latex distribution these days.

\usepackage[pdftex,
            pdfauthor={Your Name},
            pdftitle={The Title},
            pdfsubject={The Subject},
            pdfkeywords={Some Keywords},
            pdfproducer={Latex with hyperref, or other system},
            pdfcreator={pdflatex, or other tool}]{hyperref}
  • 1
    it might be worth adding a note that this is the better answer, especially if using Xe[La]TeX – Brent.Longborough Aug 25 '11 at 23:38
  • 8
    What's the difference between pdfproducer and pdfcreator? – lpdbw Aug 10 '12 at 9:59
  • What's the difference between your two solutions? @Brent.Longborough why this solution is better? – Red Jun 24 '13 at 15:33
  • 1
    Isn't pdfproducer and pdfcreator set automatically? At least this seems to be the case for me... – Martin Thoma Jun 14 '15 at 10:50
  • 2
    All of these options (and more) are documented (with their default values) in the hyperref manual, section 3.9 Big alphabetical list. – Lekensteyn May 28 '16 at 22:29
41

Use the \pdfinfo macro, where the contents are given in PDF notation:

\pdfinfo{
   /Author (Nicola Talbot)
   /Title  (Creating a PDF document using PDFLaTeX)
   /CreationDate (D:20040502195600)
   /Subject (PDFLaTeX)
   /Keywords (PDF;LaTeX)
}

(Source: http://theoval.cmp.uea.ac.uk/~nlct/latex/pdfdoc/pdfdoc/pdfdoc.html)

  • 4
    In combination with hyperref package it might cause some problems like described here. Just wanted to mention this, since I just experienced the same problem. – incBrain Jul 4 '16 at 14:32
29

As others have already answered, I like to use hyperref. However, as my documents often have \author and \title commands I do not want to repeat myself in the package parameters. Luckily, hyperref also has a parameter for that. If you want it to read the information from your \author and similar tags, simply include it like this:

\usepackage[pdfusetitle]{hyperref}
  • That is a nice option, but if you're using several \author tags it only seems to include the last one. – Anyon Apr 24 '18 at 19:35
  • Which version of hyperref has this option? Version from Jan 2017 does not seem to. – Ilya Popov Sep 3 '18 at 17:15
  • @IlyaPopov which version exactly do you use? It works for me with current version 2018/02/06 v6.86b and I doubt very much it does not work with "Jan 2017" version. – jfbu Sep 4 '18 at 6:58
  • 1
    @jfbu Oh, I see now. So, it is documented in README, but not in the manual.pdf for some reason. – Ilya Popov Sep 4 '18 at 20:33
  • 1
    @IlyaPopov this is also the case of important other things such as bookmarksdepth for example. – jfbu Sep 4 '18 at 21:05
3

You can use xmpincl, "which allows you to add arbitrary metadata in the Adobe XMP (Extensible Metadata Platform) format. But you have to write a separate XML file to do this" (suggested in threads here). They also propose a more recent package hyperxmp.

You can find an example .xmpdata file and other files needed on creating high-quality PDF/A documents using LaTeX.

This instruction not only provides files that work better than TeXLive standard packages for inclusion of metadata (they fixed some bugs), but also shows how to create PDF/A which has very good properties optimized for long-term archiving.

1

You explicitly asked for generating the metadata from LaTeX, and using one of the answers of Ken Bloom seems the right way for me.

For the case that you want to add metadata to a file not created with LaTex (or an existing pdf you do not want to recompile) I just wanted to point you to http://www.bureausoft.com/products.html#PDF%20Info%20%28Freeware%29 which is a free Windows programme to change the pdf metadata. (I do not recommend this instead of the pdfLaTeX way!)

  • 1
    For this you can even use the hyperref package as stated above in a blank document where you just import your desired PDF using the pdfpages package. – Andrestand Jul 24 '15 at 14:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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