3

Edit: Apparently hyperxmp and pdfx are incompatible.

I'm using the pdfx, and then \hypersetup and the hyperxmp package to set metadata as I like. I've run into two issues.

  1. The metadata doesn't seem to be set now I'm using pdfx.
  2. 'pdftitle has already been set' etc. warnings.

Any suggestions?

MWE

\documentclass{scrartcl}
\usepackage[a-3u,pdf17]{pdfx}

\title{BMC}
\subtitle{Pret\ldots}
\author{me}

\usepackage{hyperref}
\usepackage{hyperxmp}

\hypersetup{
    pdftitle={\@title},
    pdfauthor={\@author},
    pdfcreator=pdfLaTeX,
    pdfproducer={\@author},
    pdfapart=3, % need hyperxmp for this
    pdfaconformance=U % need hyperxmp for this
}

\begin{document}

Hello

\end{document}
  • 3
    you can't use hyperxmp and pdfx together. They are incompatible. – Ulrike Fischer Sep 30 '19 at 16:47
  • Ah. Oooops. Sorry for the dodgy question then. In that case, would you have any recommendations for how to set some of the keys like pdfaconformance? – tecosaur Sep 30 '19 at 16:53
  • 1
    It is not a dodgy question - it is one of the open problems how to get such packages to cooperate. But you don't need hyperxmp here: pdfx will set the keys, you don't need to do something. But the value is a lie: pdfx doesn't tag the pdf, so you don't have a "U" conformance. – Ulrike Fischer Sep 30 '19 at 17:16
  • I was under the impression from the documentation that it did. Also, without hyperxmp I still have no metadata set :( – tecosaur Oct 1 '19 at 3:16
  • You probably need an xmpdata file, see the documentation of pdfx (I have it lying around in my test folder from some earlier test.) – Ulrike Fischer Oct 2 '19 at 10:24
3

I don't know anything about hyperxmp, but for sure pdfx package loads xmpincl to handle the expected XMP metadata. Your problem could arise from a slight syntax confusion.

1. Your approach

\hypersetup{
    pdftitle={\@title},
    pdfauthor={\@author},
    pdfcreator=pdfLaTeX,
    pdfproducer={\@author},
}

should work, as long as :

  • you have loaded hyperref
  • you don't have loaded pdfx (see pdfx manual page 17)
  • you did'nt use \maketitle which by default empties both \@title and \@author

A MWE :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{blindtext} % for example text only
\title{A simple title}
\author{A cute author}
\usepackage{hyperref}
\makeatletter
\hypersetup{
    pdftitle={\@title},
    pdfauthor={\@author},
    pdfcreator={pdfLaTeX with hyperref},
    pdfproducer={\@author},
    pdfsubject={Some answer about metadata},
    pdfkeywords={LateX  hyperref},
}
\makeatother
\begin{document}
\blindtext
\end{document}

and the meta data shown in PDF-Xchange and Adobe Reader: enter image description here

. 2. Another option, without hyperref , using pdfLaTeX's command \pdfinfo, used as:

   \pdfinfo {   
      /Title (\@title)
      /Author (\@author)
      /Subject (\@suject)
      /Keywords (\@keywords) 
   }

The MWE :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{blindtext}
\title{A simple title}
\author{A cute author}
%\usepackage{hyperref}
\makeatletter
\pdfinfo {   
          /Title (\@title)
          /Author (\@author)
          /Subject (Some answer about metadata)
          /Keywords (LateX  hyperref) 
       }
\makeatother
\begin{document}
\blindtext
\end{document}

and the result: enter image description here

3. if you load pdfx, the metadata set relies on the \jobname.xmpdata file which could look as (see pdfx manual page 6):

\Title{Baking through the ages}
\Author{A. Baker\sep C. Kneader}
\Language{en-GB}
\Keywords{cookies\sep muffins\sep cakes}
\Publisher{Baking International}
\CoverDisplayDate{1er\ avril\ 1999}
\CoverDate{1999-04-01}

and as said in 1., \hypersetup method is disabled.

A third MWE :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{blindtext}
\usepackage[a-3b,pdf17]{pdfx}
\title{A simple title}
\author{A cute author}
%\usepackage{hyperref}
\begin{filecontents*}{\jobname .xmpdata}
\Title{Another simple title}
\Author{A cute author}
\Subject{Some answer about metadata}
\Keywords{LateX \sep hyperref} 
\end{filecontents*}
\begin{document}
\blindtext
\end{document}

and its result: enter image description here

Please notice that:

  • I used pdfa-3b as pdfa-3u is not suitable according to @UlrikeFischer answer
  • In the 3rd scheme (pdfx) the title ,is the one written in the .xmpdata, independently of \title in the main document
  • The keywords creator, producer and others of the same kind are usually automatically set by pdflatex and pdfx, and could require much more effort if you really want to customize them.
| improve this answer | |
  • Thanks for the comprehensive answer @Jhor, a few issues unfortunately: With (1) I get "Option 'pdftitle' has already been used, (hyperref) setting the option has no effect" (and no metadata), (2) gives me the title "spacefactor @m {}title", (3) looks promising. Is there any way that could be adjusted to (a) set those values dynamically (with \title etc.), and (b) do you know if I can use that for keys like pdfapart? – tecosaur Oct 2 '19 at 14:25
  • I updated my answer with three MWE and the corresponding metadata display. Yes one can set them dynamically, but it's very tricky. I can post some ideas if you ask another question specifically on this topic. I never heard anything about pdfapart – Jhor Oct 2 '19 at 17:55
  • With (a) I'm afraid I unintentionally mislead you. I meant use \title stored in \@title to set \Title. Sorry – tecosaur Oct 3 '19 at 2:02
2

pdfx as of March 2020 uses xmpincl which is incompatible with hyperxmp. But you probably don't need pdfx. Hyperxmp is the more elegant way to deal with metadata since it integrates seamlessly with hyperref and \maketitle and does not require external files. It works both with PDF/A-1b and PDF/A-3u.

%\pdfobjcompresslevel=0 %uncomment for Texlive
\documentclass{scrartcl}

\usepackage[pdfa]{hyperref}
\usepackage{hyperxmp}
\usepackage{mmap} %only needed for pdfTeX

\title{BMC}
\subtitle{Pret\ldots}
\author{me}

\hypersetup{%
    pdfapart=1,
    pdfaconformance=b
}

\immediate\pdfobj stream attr{/N 3} file{sRGB.icc}
\pdfcatalog{%
  /OutputIntents [
    <<
      /Type /OutputIntent
      /S /GTS_PDFA1
      /DestOutputProfile \the\pdflastobj\space 0 R
      /OutputConditionIdentifier (sRGB)
      /Info (sRGB)
    >>
  ]
}

\begin{document}

lorem ipsum

\end{document}
| improve this answer | |
  • I'm not sure that I can get pdf A-3u compliant without it, which is something I'm trying to do. – tecosaur Mar 26 at 7:03
  • So you have not tried my example before downvoting? Or did it not work? – tanGIS Mar 30 at 22:19
  • I didn't downvote ¯\_(ツ)_/¯ but this is why I don't think it will work, from the manual: The new option ‘pdfa’ tries to avoid violations of PDF/A in code generated by hyperref. However, the result is usually not in PDF/A, because many features aren’t controlled by hyperref (XMP metadata, fonts, colors, driver dependend low level stuff, ...). – tecosaur Mar 31 at 4:31
  • You think? I said it's working! XMP is handled by hyperxmp, fonts are automatically embedded, for colours I included some code. You are right, pdfa alone in hyperref does not to the job. – tanGIS Mar 31 at 8:27
1

Yes with solution 1 and 2, ie without pdfx you can use \@title \@author and \@date. Provided you do it before \maketitle, or patch it to avoid erasure.

My answer was related to solution 3, as a macro in a filecontents environment will be written verbatim in the file. So you will need a specific \write with small problems of encoding if you use letters out of the 128 ASCII range.

| improve this answer | |

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.