The following source, using hyperref
, shows two different ways of embedding metadata into the output from using pdflatex
:
- Using the
pdfx
package with optiona-2u
— this happens when the flagvalidate
is set totrue
, as it is below. - Using instead the
hyperxmp
package with\hyperrefset
including optionspdfapart=2, pdfaconformance=u
— this happens if the flagvalidate
is set to 'false`.
Both methods seem to embed essentially the same metadata about title, author, etc., into the pdf.
Questions:
- Aside from passing PDF/A-2U validation (which method 1 allows but method 2 does not), in fact is there any actual difference in the embedded metadata?
- Is there some reason to prefer one method to the other (aside the issue PDF/A-2U validation)?
Source:
\RequirePackage{filecontents}
\begin{filecontents}{\jobname metadata.xmp}
\hyxmp@at@end{%
% Create XMP code and write it to macro \hyxmp@xml
% (cf. hyperxmp.sty, \hyxmp@construct@packet (ll. 847-868))
\gdef\hyxmp@xml{}%
\hyxmp@add@to@xml{%
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1-702">^^J%
___<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns\hyxmp@hash">^^J%
}%
\hyxmp@pdf@schema
\hyxmp@xmpRights@schema
\hyxmp@dc@schema
\hyxmp@photoshop@schema
\hyxmp@photometa@schema
\hyxmp@xmp@basic@schema
\hyxmp@mm@schema
\hyxmp@add@to@xml{%
___</rdf:RDF>^^J%
</x:xmpmeta>^^J%
}%
}
\end{filecontents}
\begin{filecontents}{\jobname.xmpdata}
\Title{A Book}
\Author{Anonymous}
\Language{en-US}
\Keywords{things\sep stuff}
\Subject{matters}
\Publisher{Anonymous}
\Copyright{\copyright 2020 The Company CC-BY-NC-ND}
\CopyrightURL{https://creativecommons.org/licenses/by-nc-nd/4.0/}
\PublicationType{book}
\Lastpage{3}
\Date{2020-06-26}
\CoverDisplayDate{June\ 26,\ 2020}
\CoverDate{2020-06-26}
\end{filecontents}
\documentclass{book}
\usepackage{ifthen}
\newboolean{validate}
\setboolean{validate}{true}
\ifthenelse{\boolean{validate}}%
{\RequirePackage[a-2u]{pdfx}%
\pdfglyphtounicode{EM}{0058 0058 0058 0058 0058 0058 0058 0058}%
\pdfglyphtounicode{NUL}{0060 0060 0060 0060 0060 0060 0060 0060}%
\RequirePackage[type={CC},modifier={by-nc-nd},version={4.0},lang={english}]{doclicense}
\usepackage{hyperref}
\hypersetup{
pdfa,
bookmarksnumbered,
pdftitle={A Book}, pdfauthor={Anonymous}, pdfcreator={somebody},
pdfsubject={A general introducton to things}, pdfkeywords={things, stuff},
} %
}%
{\RequirePackage{hyperxmp} % to add CC info into pdf
\RequirePackage[type={CC},modifier={by-nc-nd},version={4.0},lang={english}]{doclicense}
\usepackage[pdfa]{hyperref}
\hypersetup{
pdfapart=2, pdfaconformance=u,
bookmarksnumbered,
pdftitle={A Book}, pdfauthor={Anonymous}, pdfcreator={somebody},
pdfsubject={A general introducton to things}, pdfkeywords={things, stuff},
pdflicenseurl={http://creativecommons.org/licenses/by-nc-nd/4.0/}
}%
\immediate\pdfobj stream attr{/N 3} file{sRGB.icc}
\pdfcatalog{%
/OutputIntents [
<<
/Type /OutputIntent
/S /GTS_PDFA2
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (sRGB)
/Info (sRGB)
>>
]
}
}
\newcommand\mytitle{A Book}
\newcommand\myauthor{Anonymous}
\newcommand\myabstract{An introduction to things in general.}
\newcommand\mydate{\today}
\title{\mytitle}
\author{\myauthor}
\date{\mydate}
\usepackage{newtxtext,newtxmath}
\usepackage[french,ngerman,russian,main=english]{babel}
\usepackage{blindtext}
\begin{document}
\maketitle
\blindmathpaper
\end{document}
Related:
Validate pdf with and without pdfx
pdfx + hyperref prevents setting PDF metadata [incompatible packages]
doclicense
part of the problem? Also you claim hyperxmp would not validate but you do not state which validator threw which error. Clearly/S /GTS_PDFA2
is wrong it should be/S /GTS_PDFA1
. I am not able to compile a minimal document withnewtx
and\blindmathpaper
. Dozens of compiler errors about missing or wrong metrics.