1

besides the printed book an e-book version is planned and the publisher requires certain XMP metadata to be set for it. More specifically Title, Author, Copyright-Status, Copyright-Notice and Copyright-URL. For me personally I would like to store the git hash it was created from as well.

This is what I tried:

\documentclass{scrbook}

\immediate\write18{git log -1 --format="\@percentchar H " > currentVersionLong}

\usepackage{hyperxmp}
\usepackage{hyperref}
\hypersetup{%
    pdftitle={The title},
    pdfauthor={The author},
    pdfcopyright={\textcopyright\ 2020 by the publisher},
%   pdfversionid={\IfFileExists{currentVersionLong}{\input{currentVersionLong}}{No version information}},
    pdflicenseurl={https://tex.stackexchange.com}
}

\begin{document}
    Just an empty document
\end{document}

However there are two issues:

  1. If I check the PDF in Adobe Reader, I can only see this information: enter image description here

enter image description here

Shouldn't I see the data here, or do I need to inspect the PDF file uncompressed in Notepad++?

  1. I want to read the current git has from the command line writing it to a file through write18. However the line pdfversionid={\IfFileExists{currentVersionLong}{\input{currentVersionLong}}{No version information}}, is not liked by hyperxmp. An idea how I can maybe read this into a macro first and then use it that way?

2 Answers 2

3

hyperxmp fills the so-call xmp-metadata. You can check them by looking in the pdf (normally they are uncompressed even if the rest of the pdf is compressed. They start with

<<
/Type /Metadata /Subtype /XML 
/Length 8178      
>>
stream
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <rdf:Description rdf:about=""
....

The screenshots in your question show mainly the content of the Info dictionary (the adobe reader will also use values from the xmp metadata, so it could be a mix of both). You can add more values there with the pdfinfo key:

\hypersetup{%
    pdftitle={The title},
    pdfauthor={The author},
    pdfinfo={Copyright=some copyright info, 
            licence=https://tex.stackexchange.com}
}

would give

enter image description here

You can use the catchfile package to catch some file content inside a macro and then use in the metadata.

7
  • Thanks for the answer, my investigation showed however that starting from a certain file size, the XMP gets compressed, too. This is why I overlooked the XMP at first, it was in my file, but I couldn't see it through Notepad++ or Adobe Reader. This is the next catch, the actual XMP data can not be viewed through Adobe Reader, you need Adobe Acrobat DC at least to have the Additional Metadata... button in the description. The additional pdfinfo is however helpful for data to see for everybody.
    – TobiBS
    Jun 22, 2020 at 12:52
  • And catchfile is great, in my example I used \immediate\write18{git log -1 --format="\@percentchar H" > currentVersionLong} and then \IfFileExists{currentVersionLong}{\CatchFileDef{\githashlong}{currentVersionLong}{}}{\newcommand{\githashlong}{No commit info}} to store everything in \githashlong and then use it for the XMP and PDF data.
    – TobiBS
    Jun 22, 2020 at 13:43
  • This answer, although accepted is not really true. The info dictionary is shown when present. However, when only XMP is present XMP is shown. And info dictionary is deprecated. It's better to use XMP only.
    – tanGIS
    Jul 3, 2020 at 13:38
  • @tanGIS and do you know a way to suppress the info dictionary completly with pdftex? Jul 3, 2020 at 13:58
  • @UlrikeFischer hyperxmp handles this automatically unless you set keeppdfinfo. DocumentInfo is never suppressed completely. CreationDate and ModDate should always be present there. The big difference is that XMP can handle tags in different languages and lists which matters for keywords and the list of used languages.
    – tanGIS
    Jul 3, 2020 at 14:11
2

Try this

\documentclass{scrbook}

\usepackage{hyperxmp}
\usepackage{hyperref}
\usepackage{gitver}

\title{The title}
\author{The author}

\hypersetup{%
   pdfcopyright={\textcopyright\ 2020 by the publisher},
   pdfversionid=\gitVer,
   pdflicenseurl={https://tex.stackexchange.com}
}

\begin{document}
    Just an empty document
\end{document}

And you see your data under «additional metadata»: Acrobat screenshot file properties Acrobat screenshot advanced metadata

Since I have no git repository the value is «unknown».

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .