latex3 / pdfresources

LaTeX PDF resource management
LaTeX Project Public License v1.3c
22 stars 8 forks source link

[Support] What happen to `hyperref` when the PDF management will be out of the testphase? #82

Closed miticollo closed 2 weeks ago

miticollo commented 2 weeks ago

Yesterday, I discovered \DocumentMetadata and I started to look around to understand how to switch from pdfx to \DocumentMetadata. This decision was also motivated by this comment.

Searching on Google, I discovered that \DocumentMetadata was introduced with the 2022-06-01 LaTeX kernel update. Then I read this publication because IMO it clear explains why \DocumentMetadata is introduced starting with an overview on previous packages, as pdfx that I knew.

I understood that \DocumentMetadata is a kernel command but at the moment the PDF management is in testphase. For this reason, the only way to add some Metadata is to use \hypersetup like reported here: hypersetup

But the thing that amazed me was hyperref-generic module. Always in the previous publication is reported: hyperref Furthermore, l3pdfmeta reports: https://github.com/latex3/pdfresources/blob/959db881f48fa1070af7d122f42074f337b0ee31/l3pdfmeta.dtx#L395-L396 Based on hyperref-generic doc, it seems that this is not a temporary module: https://github.com/latex3/pdfresources/blob/959db881f48fa1070af7d122f42074f337b0ee31/hyperref-generic.dtx#L91-L92 If I'm not wrong, this generic driver required hyperref. But in this way hyperref is always required?

To be more clear, what I would expect is the following. During testphase you must load hyperref

\DocumentMetadata{pdfstandard=A-2b} 
\documentclass{book}
\usepackage{hyperref}
\hypersetup{pdfauthor=Ulrike Fischer,pdftitle=pdf/A-2b standard}

\begin{document}
abc
\end{document}

When the PDF management will be merged into l3kernel (like l3pdf), hyperref is no more strictly necessary to add Metadata to PDF:

\DocumentMetadata{
pdfstandard=A-2b,
pdfauthor=Ulrike Fischer,    % this is an example, this key doesn't exist (at the moment, maybe in the future?)
pdftitle=pdf/A-2b standard,  % this is an example, this key doesn't exist (at the moment, maybe in the future?)
} 
\documentclass{book}
\usepackage{hyperref}
%\hypersetup{pdfauthor=Ulrike Fischer,pdftitle=pdf/A-2b standard}

\begin{document}
abc
\end{document}

Example taken from this answer.

u-fischer commented 2 weeks ago

Strictly speaken you do not need hyperref to add these metadata. You can e.g. use the title-module in the latex-lab bundle:

\DocumentMetadata{
pdfstandard=A-2b,
testphase={title},
} 
\documentclass{book}
\title[pdftitle=pdf/A-2b Standard]{A longer title}
\author{Ulrike Fischer}

\begin{document}
abc
\end{document}

And yes the plan is to add keys to \DocumentMetadata that can be used in a similar way. The main problem is to come up with a good set of keys and key names ...

miticollo commented 2 weeks ago

Thank Ulrike for your answer!

I tried a more complicated example:

\DocumentMetadata{
pdfstandard=A-3b,
lang={it-IT,en-US},
} 
\documentclass{toptesi}

\usepackage[verbose]{hyperref}
\hypersetup{
pdfmetalang = {it-IT,en-US},
pdftitle    = {Da iOS stock ad AnForA},
pdfauthor   = {Lorenzo Ferron},
pdfsubject  = {Da iOS stock ad AnForA},
pdfkeywords = {Master's Degree, italian, iOS, AnForA},
pdfsubtitle = {Studio di fattibilità con metodo bottom-up e realizzazione di un PoC di AnForA in ambito iOS},
pdfcaptionwriter = {Lorenzo Ferron},
pdfcontactcity = {Alessandria},
pdfcontactcountry = {Italia},
pdfcontactemail = {john.doe@studenti.uniupo.it},
pdfcontactpostcode = {15122},
}
\AddToDocumentProperties[document]{copyright}{false}

\begin{document}
abc
\end{document}

I compiled it with

latexmk -interaction=nonstopmode -lualatex ./foo.tex

and I inspected XMP with

pdfinfo -meta ./foo.pdf

Everything works!

But at the moment it is not possible to remove \usepackage{hyperref}, right? And in the future, when hyperref is no more required the above code will be still compatible? I mean TeX files produced now will be compatible when a good set of keys and key names will be available?

u-fischer commented 2 weeks ago

But at the moment it is not possible to remove \usepackage{hyperref}, right?

Well you can, all the keys simply store they data into the DocumentProperties and from there the metadata code gets them. But the interface is not yet stable here - the names and the place where the data is store can (will probably) change. Beside this if you want to add stuff to the Info dictionary you must convert it into a PDF string, and this is easier if you have the hyperref tools available.

\DocumentMetadata{uncompress,
pdfstandard=A-3b,
lang={it-IT,en-US},
} 
\documentclass{toptesi}

\AddToDocumentProperties[hyperref]{pdfauthor}{Lorenzo Ferror}
\AddToDocumentProperties[hyperref]{pdfcontactcity}{Alessandria}
\AddToDocumentProperties[document]{copyright}{false}
\ExplSyntaxOn
\pdfmanagement_add:nnn{Info}{Author}{(Lorenzo Ferror)}
\ExplSyntaxOff
\begin{document}
abc
\end{document}

And in the future, when hyperref is no more required the above code will be still compatible?

Yes. But if you use \hypersetup you will have to load hyperref.

miticollo commented 2 weeks ago

Thank Ulrike to have answered my questions! Now I know that \DefaultMetadata + \hypersetup will be safe in future. I think that I can switch from pdfx to \DefaultMetadata. So I can switch from PDF/A-3b to PDF/A-3a + PDF/UA-1 for my master degree thesis.