So I know one of hyperref's features is that it can add metadata to you PDFs. This is a nice feature and if you're putting stuff online, it's good to include metadata.

But is the hyperref package really the best way to do it? I mean, if you're using hyperref anyway, that's fine. But if you don't want hyperrefs in your document, it seems weird to include the package, and then turn off pretty much all its functionality. And given that hyperref is a shorthand for "package conflict nightmare", is seems insane that you should have to deal with it just for the sake of some metadata.

So I have two questions.

  1. Is there a good reason that hyperref includes this functionality which is apparently unrelated to its primary purpose?
  2. Is there a better (smaller, less conflicty, easier...) option to include metadata in my PDFs?

You could use the \pdfinfo command of pdfTeX to add meta data. For example:

  /Title (example.pdf)
  /Creator (TeX)
  /Producer (pdfTeX 1.40.0)
  /Author (Seamus)
  /Subject (Example)
  /Keywords (pdflatex, latex,pdftex,tex)}

There's no need to load a package for that purpose. This command is explained in the pdfTeX documentation.

  • 6
    Holy cow: \usepackage{titling} \title{Foo} \pdfinfo{/Title (\thetitle)} WORKS! I was not expecting that... – Seamus Nov 26 '10 at 12:00
  • 1
    This doesn't seem to work if hyperref is used. Not a big deal but slightly annoying since it means I have to move the information if I want to add or remove hyperref at some point. It also means that if I have included hyperref in a file common to several documents, I can't set the title separately for each. – Max May 28 '12 at 8:41
  • 2
    It works for me when I use \AtBeginDocument, as in tex.stackexchange.com/a/304758 – Nathan Musoke Jun 2 '16 at 10:34
  • For the language, it appears you need \pdfcatalog{/Lang(EN-US)}. – Teepeemm Apr 18 '19 at 2:24
  • This answer is completely outdated. It still works but nowadays the main interface for metadata today is XMP. The code above only creates Document Info metadata not XMP. Use hyperxmp to include standardised metadata or xmpincl for arbitrary metadata. – tanGIS Jul 13 '20 at 20:55

There is 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. I always thought there should be a LaTeX way to create an XMP file on the first pass and embed it in the PDF on the second pass. But so far I know of none.

  • Make use of the filecontents package and the filecontents* environment (yes, with star). – Speravir Nov 1 '13 at 0:51
  • @Speravir: filecontents would allow me to write text to a file verbatim, true. I'm thinking more of a process that would dynamically generate the XMP file. Since I made the original comment, I have learned that the attachfile and attachfile2 packages can be used for the embedding part of the task. – Matthew Leingang Nov 1 '13 at 15:29

hyperxmp – Embed XMP metadata within a LATEX document


" ... The pack­age in­te­grates seam­lessly with hy­per­ref and re­quires vir­tu­ally no mod­i­fi­ca­tions to doc­u­ments that al­ready ex­ploit hy­per­ref's mech­a­nisms for spec­i­fy­ing PDF meta­data..

"XMP (eXten­si­ble Me­ta­data Plat­form) is a mech­a­nism pro­posed by Adobe for em­bed­ding doc­u­ment meta­data within the doc­u­ment it­self. The meta­data is de­signed to be easy to ex­tract, even by pro­grams that are obliv­i­ous to the doc­u­ment's file for­mat. Most of Adobe's ap­pli­ca­tions store XMP meta­data when sav­ing files. Now, with the hy­per­xmp pack­age, it is triv­ial for LaTeX doc­u­ment au­thors to store XMP meta­data in their doc­u­ments as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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