0

I'm trying to add metadata to the pdf generated from the compilation of my .tex document.

I understand that this is a functionality offered by the hyperref package but I am not able to make it work, since my fields pdftitle, pdfauthor and pdfcreator are not sticking. I get the following errors in my log:

 - "Option `pdftitle' has already been used,(hyperref) setting the option has no effect"
 - "Option `pdfauthor' has already been used,(hyperref) setting the option has no effect"
 - "Option `pdfcreator' has already been used,(hyperref) setting the option has no effect"

I don't see where this could have happened, since I don't set it explicitly in my document.

Here is my MWE code to illustrate the kind of metadata I'm trying to embed.

\ExplSyntaxOn

    %%%% Definition of the title and the author name
    \str_const:Nn \c_authorName_str {Firstname~NAME}
    
    \title{CV \str_use:N \c_authorName_str}
    \author{\str_use:N \c_authorName_str}
    
    %%%%  Call to hyperref juste before to initialize the document.
    \usepackage[unicode]{hyperref}
    %   \usepackage[unicode,pdftitle={CV \str_use:N \c_authorName_str},pdfauthor={\str_use:N \c_authorName_str},pdfcreator={\str_use:N \c_authorName_str}]{hyperref}
    
    \AtBeginDocument{
        \hypersetup{
            pdftitle={CV \str_use:N \c_authorName_str},
            pdfauthor={\str_use:N \c_authorName_str},
            pdfcreator={\str_use:N \c_authorName_str}
        }
    }

\ExplSyntaxOff

%%%%% CONTENU
\begin{document}
    
%%%%  CV Header
\ExplSyntaxOn
    \name{\str_use:N \c_authorName_str}
\ExplSyntaxOff

As I've said in the title, I am compiling my document with the Luatex engine.

3
  • 1
    luatex is irrelevant. You are probably using the pdfx package which disables the option. Mar 4, 2021 at 21:06
  • Can you link us to an actual PDF? Are you also embedding other XML-based metadata, using pdfx or hyperxmp?
    – Ingmar
    Mar 5, 2021 at 5:49
  • @UlrikeFischer You were right. Since I built my document on top of another Latex template, I didn't noticed but it used the pdfx package. Since it doesn't have so much interest in my case, I erased the call and now all the metadata is generated as expected. I guess it is a kind of "classic" since you guessed without my package calls ? Thank you so much for the tips ! Mar 8, 2021 at 15:11

2 Answers 2

1

This is the setup it works for me. It does not work using commands in the \hypersetup.

    % !TeX TS-program = lualatex

\documentclass[12pt,a4paper]{book}

\usepackage[
hyperindex=true,    % Makes the page numbers of index entries into hyperlinks
bookmarks=true,% PDF-specific display options
]{hyperref}

\hypersetup{
    pdftitle={Integrate pdf metadata while using the Luatex engine},
    pdfauthor={impishwhite},
    pdfsubject={pdf metadata},
    pdfkeywords={hyperref},
    pdfcreator={me again},
    bookmarksnumbered=true,     
    bookmarksopen=true, 
    linktocpage=true, % in the table of contents, make page numbers rather (than associated text) into hyperlinks
} 

\author{impishwhite}
\title{Integrate pdf metadata while using the Luatex engine}

\begin{document}
\maketitle  
\chapter{One}   
\chapter{Two}   
\end{document}

b

This is with acrobat reader

c

1
  • I finally made it work thanks to Ulrick and Ingmar. I had a call to the "pdfx" package and this one broke the possibility to generate the metadata from the hyperref package. Problem solved, thank you :) Mar 8, 2021 at 15:14
1

The problem was that two packages with pdf metadata configuration capabilities were used in parallel in my document. Indeed, I had both "hyperref" and "pdfx".

The mechanism for metadata configuration triggered by the call to the pdfx package impede the possibilities for metadata configuration offered by the hyperref package.

To delete the use of the pdfx package made the problem disapear and my code worked correctly without more modifications.

Thank you for your help.

You must log in to answer this question.

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