The pdfx
package documentation recommends to use a file \jobname.xmpdata
to supply PDF metadata. This can be handled by using the filecontents
environment. However, that makes macros useless, making it non-trivial to include the document wide title and author.
Are there any ways in plain LaTeX to work around having to type the metadata in more than one place of the document? Something like sed scripts would not be expected to work on all platforms.
\documentclass{article}
\usepackage[a-1b]{pdfx}
\title{Example}
\author{John Doe}
\makeatletter
\begin{filecontents}{\jobname.xmpdata}
\Title{\@title}
\Author{\@author}
\end{filecontents}
\makeatother
\begin{document}
test
\end{document}
which results in the following xmpdata, using non-escaped title and author
%% LaTeX2e file `main.xmpdata'
%% generated by the `filecontents' environment
%% from source `main' on 2017/06/03.
%%
\Title{\@title}
\Author{\@author}