Debian Codegraph @

texmf-dist/source/latex/pdfmanagement/l3pdfmeta.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: l3pdfmeta.dtx
4 %
5 % Copyright (C) 2018-2026 The LaTeX Project
6 %
7 % It may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License (LPPL), either version 1.3c of this
9 % license or (at your option) any later version. The latest version
10 % of this license is in the file
11 %
12 % http://www.latex-project.org/lppl.txt
13 %
14 % This file is part of the "LaTeX PDF management bundle" (The Work in LPPL)
15 % and all files in that bundle must be distributed together.
16 %
17 % -----------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/latex3/pdfresources
22 %
23 % for those people who are interested.
24 %
25 %<*driver>
26 \DocumentMetadata{tagging=on,pdfstandard=ua-2}
27 \documentclass[full]{l3doc}
28 \usepackage{latex-lab-testphase-l3doc} %
29 % see issue https://github.com/latex3/tagging-project/issues/925
30 \EditInstance{blockenv}{displayblock}{inner-instance =}
31 \usepackage{array,booktabs}
32 \hypersetup{pdfauthor=The LaTeX Project,pdftitle=l3pdfmeta (LaTeX PDF management bundle)}
33
34 \begin{document}
35 \DocInput{\jobname.dtx}
36 \end{document}
37 %</driver>
38 % \fi
39 %
40 % \title{^^A
41 % The \pkg{l3pdfmeta} module\\ PDF standards ^^A
42 % \\
43 % \LaTeX{} PDF management bundle
44 % }
45 %
46 % \author{^^A
47 % The \LaTeX{} Project\thanks
48 % {^^A
49 % E-mail:
50 % \href{mailto:[email protected]}
51 % {[email protected]}^^A
52 % }^^A
53 % }
54 %
55 % \date{Version 0.97c, released 2026-05-26}
56 %
57 % \maketitle
58 % \begin{documentation}
59 %
60 % \section{\pkg{l3pdfmeta} documentation}
61 % This module sets up some tools and commands needed
62 % for PDF standards in general.
63 % The goal is to collect the requirements and to provide code to check and fulfill them.
64 %
65 % \subsection{Standard families}
66 %
67 % A PDF can claim that it complies to more than one standard but always only to one
68 % version of a specific family. For \LaTeX{} relevant are the A-, UA- and X-standards.
69 %
70 % The \pkg{l3pdfmeta} module started with support for the A-standards,
71 % some basic support for UA- and X-requirements were added in a rather ad-hoc way because
72 % there isn't a easy way to merge requirements and because a merge loses
73 % the option to report for which standard a requirement failed: if e.g. A-4 requires PDF 2.0
74 % and UA-1 PDF 1.7 it is not clear what a merge should do.
75 %
76 % So instead of merging the requirements the code now keeps track of the requirements of standard
77 % \emph{families} (currently A, UA and X)
78 % and offers a command to switch the family to enable validation of their requirements.
79 % The default family is always the A-family -- it has the largest numbers of requirements and
80 % also the largest numbers of requirements that the code can actually check.
81 %
82 %
83 % \subsection{Verifying requirements of PDF standards}
84 %
85 % Standards like pdf/A set requirements on a PDF: Some things have be in the PDF,
86 % e.g. the catalog has to contain a /Lang entry and an colorprofile and
87 % an /OutputIntent, some other things are forbidden or restricted, e.g.
88 % the action dictionary of an annotation should not contain Javascript.
89 %
90 % The \pkg{l3pdfmeta} module collects a number of relevant requirements,
91 % tries to enforce the ones which can be enforced and offers some tools
92 % for package authors to test if an action is allowed in the standard or not.
93 %
94 % This is work in progress and more tests will be added. But it should be noted
95 % that it will probably never be possible to prevent all forbidden actions
96 % or enforce all required ones or even to simply check all of them.
97 % The commands here don't replace a check with an external validator.
98 %
99 % Verifying against a PDF-standard involves two different task:
100 %
101 % \begin{itemize}
102 % \item Check if you are allowed to ignore the requirement.
103 % \item Decide which action to take if the answer to the first question is NO.
104 % \end{itemize}
105 %
106 % The following conditionals address the first task. Because of the second task
107 % a return value |FALSE| means that the standard requires you to do some
108 % special action. |TRUE| means that you can ignore this
109 % requirement.\footnote{One could also make the logic the
110 % other way round---there are arguments for both---but I had to decide.}
111 %
112 % In most cases it only matters if a requirement is in the standard,
113 % for example |Catalog_no_OCProperties| means \enquote{don't use |/OCProperties|
114 % in the catalog}. For a small number of requirements it is also needed to
115 % test a user value against a standard value. For example, |named_actions|
116 % restricts the allowed named actions in an annotation of subtype |/Named|,
117 % in this case it is needed to check not only if the requirement is
118 % in the standard but also if the user value is in the allowed list.
119 %
120 % \begin{function}{\pdfmeta_standard_family:nn}
121 % \begin{syntax}
122 % \cs{pdfmeta_standard_family:nn} \Arg{family} \Arg{code}
123 % \end{syntax}
124 % This command allows to change the family for which requirements should be checked.
125 % \meta{family} should be one of \texttt{A}, \texttt{X} or \texttt{UA}. The function
126 % switches to the requirements of this family, then executes \meta{code} and then switches
127 % back to the A-standard family (this means that the command is not needed for a test
128 % of an A-standard requirement as that is the default anyway). \meta{code} can do testing
129 % or retrieve values or other things but it shouldn't contain another \cs{pdfmeta_standard_family:nn}.
130 % \end{function}
131 %
132 % \begin{function}[EXP,TF]{\pdfmeta_standard_verify:n}
133 % \begin{syntax}
134 % \cs{pdfmeta_standard_verify:nTF} \Arg{requirement} \Arg{true code} \Arg{false code}
135 % \end{syntax}
136 %
137 % This checks if \meta{requirement} is listed in the standard.
138 % |FALSE| as result means that the requirement is in the standard and
139 % that probably some special action is required---which one depends
140 % on the requirement, see the descriptions below.
141 % |TRUE| means that the requirement is not there and so no special
142 % action is needed.
143 % This check can be used for simple requirements where neither
144 % a user nor a standard value is of importance.
145 % \end{function}
146 %
147 % \begin{function}[TF]{\pdfmeta_standard_verify:nn}
148 % \begin{syntax}
149 % \cs{pdfmeta_standard_verify:nnTF} \Arg{requirement} \Arg{value} \Arg{true code} \Arg{false code}
150 % \end{syntax}
151 %
152 % This checks if \meta{requirement} is listed in the standard,
153 % if yes it tries to find a predefined test handler for
154 % the requirement and passes \meta{value} and the value recorded
155 % in the standard to it. The handler returns |FALSE| if some special
156 % action is needed (e.g. if \meta{value} violates the rule)
157 % and |TRUE| if no special action is needed. If no handler exists
158 % this commands works like \cs{pdfmeta_standard_verify:n}.
159 % \end{function}
160 %
161 % In some cases one needs to query the value in the standard,
162 % e.g. to correct a wrong minimal PDF version you need to know
163 % which version is required by |min_pdf_version|.
164 % For this two commands to access the value are provided:
165 %
166 % \begin{function}[EXP]{\pdfmeta_standard_item:n}
167 % \begin{syntax}
168 % \cs{pdfmeta_standard_item:n} \Arg{requirement}
169 % \end{syntax}
170 % This retrieves the value of \meta{requirement} and leaves it in the input.
171 % If the requirement isn't in the standard the result is empty,
172 % that means that requirements not in the standard and
173 % requirement without values can not be distinguished here.
174 % \end{function}
175 %
176 %
177 % \begin{function}{\pdfmeta_standard_get:nN}
178 % \begin{syntax}
179 % \cs{pdfmeta_standard_get:nN} \Arg{requirement} \meta{tl var}
180 % \end{syntax}
181 % This retrieves the value of \meta{requirement} and stores
182 % it in the \meta{tl var}.
183 % If the \meta{requirement} is not found the special
184 % value |\q_no_value| is used.
185 % The \meta{tl var} is assigned locally.
186 % \end{function}
187 %
188 %
189 % The following describe the requirements which can be currently tested.
190 % Requirements with a value should use \cs{pdfmeta_standard_verify:nn}
191 % or \cs{pdfmeta_standard_verify:nnN} to test a local value against the standard.
192 % The rule numbers refer to \url{https://docs.verapdf.org/validation/pdfa-part1/}
193 %
194 % \subsubsection{Simple tests without handler}
195 %
196 % \begin{description}
197 %
198 % \item[|outputintent_A|] requires to embed a color profile and
199 % reference it in a /Outputintent and that all output intents reference
200 % the same colorprofile. The value stores the subtype.
201 % {\em This requirement is detected and fulfilled by \pkg{l3pdfmeta} if the
202 % provided interface in \cs{DocumentMetadata} or \verb+\SetKeys[document/metadata]+
203 % is used, see below}.
204 %
205 % \item[|annot_flags|] in annotations the |Print| flag should be true,
206 % |Hidden|, |Invisible|, |NoView| should be false.
207 % {\em This requirement is detected and set by \pkg{l3pdfmeta} for annotations
208 % created with the \pkg{l3pdfannot}.
209 % A new check is only needed if the flags are changed
210 % or if links are created by other means.}
211 %
212 % \item[|no_encryption|] don't encrypt
213 % \item[|no_external_content|] no |/F|, |/FFilter|, or |/FDecodeParms|
214 % in stream dictionaries
215 % \item[|no_embed_content|] no |/EF| key in filespec, no |/Type/EmbeddedFiles|.
216 % \emph{This will be checked in future by \pkg{l3pdffiles}
217 % for the files it embeds.}
218 % The restriction is set only for PDF/A-1 versions.
219 % PDF/A-2 and PDF/A-3 lifted this restriction: PDF/A-2 allows
220 % to embed other PDF documents conforming to either PDF/A-1 or PDF/A-2,
221 % and PDF/A-3 and PDF/A-4F allows any embedded files.
222 %
223 % \item[|only_pdfa_embed_content|]
224 % This is set for PDF/A-2a, PDF/A-2b, PDF/A-2u and PDF/A-4.
225 % I don't see a way to test the
226 % PDF/A-2 requirement so currently it will simply allow everything. Perhaps
227 % a test for at least the PDF-format will be added in future.
228 %
229 % \item[|Catalog_no_OCProperties|] don't add |/OCProperties| to the catalog
230 % {\em l3pdfmeta removes this entry at the end of the document}
231 % \item[|Catalog_OCProperties_no_AS|]
232 % do not use |/AS| optional content configuration dictionary.
233 % \item[|Catalog_EmbeddedFiles|] ensure that an |EmbeddedFiles| name tree is
234 % in the catalog. This is required for PDF/A-4f.
235 % \item[|annot_widget_no_AA|] (rule 6.6.2-1)
236 % no AA dictionary in widget annotation,
237 % this will e.g. be checked by the new hyperref driver.
238 % \item[|annot_widget_no_A_AA|] (rule 6.9-2) no A and AA dictionary in widget.
239 % \item[|form_no_AA|] (6.9-3) no /AA dictionary in form field
240 % \item[|unicode|] that is set in the U-standards, A-2u and A-3u and means that
241 % every text should be in unicode. This is not something that can be enforced or
242 % tested from TeX, but in a current LaTeX normally ToUnicode are set for all fonts.
243 % \item[|tagged|] that is set in A-2a and A-3a and means that the pdf must be
244 % tagged. This is currently neither tested not enforced somewhere.
245 % \item[|no_CharSet|] CharSet is deprecated is pdf 2.0 and should not
246 % be used in A-4. l3pdfmeta will therefore suppress it for the
247 % engines pdftex and luatex (the other engines have no suitable option)
248 % \item[|omit_CID|] This avoids with PDF/A-2 and newer a failure
249 % because of with missing CID identifications
250 % (e.g. from rule ISO 19005-2:2011, Clause: 6.2.11.4.2)
251 % It has only with luatex an effect.
252 % \item[|Trailer_no_Info|] The \texttt{Info} dictionary
253 % has been deprecated since quite some time. Metadata should be set with
254 % XMP-data instead. In PDF A-4 now the \texttt{Info} dictionary
255 % shall not be present in the trailer dictionary at all
256 % (unless there exists a PieceInfo entry in the Catalog). And if it is present
257 % it should only contain the \texttt{/ModDate} entry. In
258 % texlive 2023 the engines pdftex and luatex have primitives
259 % to suppress the dictionary
260 % and l3pdfmeta will make use of it.
261 % \item[|tagged|] (A- and UA-standards) The document must be a tagged PDF.
262 % \item[|link_Contents|] (UA-standards)
263 % A link annotation must have a |Contents| entry (true for UA-1)
264 % \end{description}
265 %
266 % \subsubsection{Tests with values and special handlers}
267 %
268 % \begin{description}
269 %
270 % \item[|min_pdf_version|] stores the minimal PDF version needed for
271 % a standard.
272 % It should be checked against the current PDF version (\cs{pdf_version:}).
273 % A failure means that the version should be changed.
274 % Currently there is only one hard requirement which leads to a failure in
275 % a validator like verapdf: The A-4 standard should use PDF 2.0.
276 % As PDF A-1 is based on PDF 1.4 and PDF A-2 and A-3 are based
277 % on PDF 1.7 \pkg{l3pdfmeta} also sets these versions also as requirements.
278 % UA-2 requires PDF 2.0.
279 % These requirements are checked by \pkg{l3pdfmeta} when the standard is set with
280 % \cs{DocumentMetadata} or \verb+\SetKeys[document/metadata]+
281 % and the version is if needed changed. At the begin of the document another
282 % check is done and error is issued if the version doesn't fit as this means that
283 % the document has used conflicting standard and version setting.
284 %
285 %
286 % \item[|max_pdf_version|] stores the maximal PDF version.
287 % It should be checked against the current PDF version (\cs{pdf_version:}).
288 % A failure means that the version should be changed.
289 % The check is currently relevant for the A-1 to A-3 standards,
290 % PDF 2.0 leads to a failure in a validator like verapdf so the maximal
291 % version should be PDF 1.7, for UA-1 which requires PDF 1.7 or lower, and for UA-2
292 % which requires PDF 2.0.
293 % These requirements are checked by \pkg{l3pdfmeta} when the standard is set with
294 % \cs{DocumentMetadata} or \verb+\SetKeys[document/metadata]+
295 % and the version is if needed changed. At the begin of the document another
296 % check is done and error is issued if the version doesn't fit as this means that
297 % the document has used conflicting standard and version setting.
298 %
299 % \item[|named_actions|] this requirement restricts the list of
300 % allowed named actions to |NextPage|, |PrevPage|, |FirstPage|, |LastPage|.
301 % The check should supply the named action without slash
302 % (e.g. |View| (failure) or |NextPage| (pass)).
303 %
304 % \item[|annot_action_A|] (rule 6.6.1-1) this requirement restricts
305 % the allowed subtypes of the
306 % |/A| dictionary of an action. The check should supply the user
307 % subtype without slash e.g. as |GoTo| (pass) or |Movie| (failure).
308 % \end{description}
309 %
310 % \subsection{Colorprofiles and OutputIntent}
311 %
312 % The pdf/A standards require that a color profile is embedded and
313 % referenced in the catalog in the |/OutputIntent| array.
314 %
315 % The problem is that the pdf/A standards also require, that if the PDF has more then
316 % one entry in the |/OutputIntent| array (which is allowed), their |/DestOutputProfile|
317 % should all reference the same color profile\footnote{see rule 6.2.2-2 at
318 % \url{https://docs.verapdf.org/validation/pdfa-part1/}}.
319 %
320 % Enforcing this fully is impossible if entries are added manually by users or
321 % packages with |\pdfmanagement_add:nnn {Catalog}{OutputIntents}{|\meta{object reference}|}|
322 % as it is difficult to inspect and remove entries from the |/OutputIntent| array.
323 %
324 % So we provide a dedicated interface to avoid the need of manual
325 % user settings and allow the code to handle the requirements of the standard.
326 % The interface doesn't handle yet all finer points for PDF/X standards, e.g.
327 % named profiles, it is meant as a starting point to get at least PDF/A validation
328 % here.
329 %
330 % \begin{NOTE}{UF}
331 % The interface has to handle the following points:
332 % \begin{itemize}
333 % \item We have to assume that some documents wants to add more
334 % than one OutputIntent with varying subtypes.
335 % \item While currently only |/GTS_PDFA1| and |/GTS_PDFX| seem to
336 % be relevant, we have to assume that the list of subtypes is open.
337 % \item But we can imho assume that every subtype is there at most once.
338 % \item The referenced color profile can be used also other means, e.g. an /ICCBased
339 % color space. We must avoid that it is embedded twice in this case.
340 % This will need coordination with l3color. It should probably provide the
341 % code to embed the profile.
342 % \item While we can predeclare some standard icc-profiles, an interface to
343 % setup more is needed. This is currently not handled, as it needs
344 % coordination with a setup in l3color too.
345 % \item The implementation doesn't really handle yet all finer points for pdf/X
346 % see \url{tn0002_color_in_pdfa-1_2008-03-141.pdf}
347 % \end{itemize}
348 % \end{NOTE}
349 % The interface looks like this
350 % \begin{verbatim}
351 % \DocumentMetadata
352 % {
353 % %other options for example pdfstandard
354 % colorprofiles=
355 % {
356 % A = sRGB.icc, %or a or longer GTS_PDFA1 = sRGB.icc
357 % X = FOGRA39L_coated.icc, % or x or longer GTS_PDFX
358 % ISO_PDFE1 = whatever.icc
359 % }
360 %
361 % }
362 % \end{verbatim}
363 % or
364 % \begin{verbatim}
365 % \RequirePackage{pdfmanagement}
366 % \Setkeys[document/metadata]
367 % {
368 % %other options for example pdfstandard
369 % colorprofiles=
370 % {
371 % A = sRGB.icc, %or a or longer GTS_PDFA1 = sRGB.icc
372 % X = FOGRA39L_coated.icc, % or x or longer GTS_PDFX
373 % ISO_PDFE1 = whatever.icc
374 % }
375 %
376 % }
377 % \end{verbatim}
378 %
379 % |sRGB.icc| and |FOGRA39L_coated.icc| (from the \pkg{colorprofiles} package
380 % are predefined and will work directly\footnote{The \texttt{dvips} route
381 % will require that \texttt{ps2pdf} is called with \texttt{-dNOSAFER},
382 % and that the color profiles are in the current folder as \texttt{ps2pdf} doesn't
383 % use \texttt{kpathsea} to find them.}. |whatever.icc| will need special setup in
384 % the document preamble to declare the values for the
385 % |OutputIntent| dictionary, but the interface hasn't be added yet. This will be
386 % decided later.
387 %
388 %
389 % If an A-standard is detected or set which requires
390 % that all |/DestOutputProfile| reference the same
391 % color profile, the setting is changed to the equivalent of
392 %
393 % \begin{verbatim}
394 % \SetKeys[document/metadata]
395 % {
396 % %other options
397 % pdfstandard=A-2b,
398 % colorprofiles=
399 % {
400 % A = sRGB.icc, %or longer GTS_PDFA1 = sRGB.icc
401 % X = sRGB.icc,
402 % ISO_PDFE1 = sRGB.icc
403 % }
404 %
405 % }
406 % \end{verbatim}
407 %
408 % The pdf/A standards will use |A=sRGB.icc| by default, so this doesn't
409 % need to be declared explicitly.
410 %
411 % \subsection{Regression tests}
412 % When doing regression tests one has to set various metadata to fix values.
413
414 % \begin{function}{\pdfmeta_set_regression_data:}
415 % \begin{syntax}
416 % \cs{pdfmeta_set_regression_data:}
417 % \end{syntax}
418 % This sets various metadata to values needed by the \LaTeX{}
419 % regression tests.
420 % It also sets the seed for random functions.
421 % If a current l3backend is used and \cs{c_sys_timestamp_str} is available,
422 % the command does not set dates, but
423 % assumes that the environment variable \verb+SOURCE_DATE_EPOCH+ is used.
424 % \end{function}
425 %
426 % \section{XMP-metadata}
427 % XMP-metadata are data in XML format embedded in a stream
428 % inside the PDF and referenced from the |/Catalog|.
429 % Such a XMP-metadata stream contains various document related data,
430 % is required by various PDF standards and can replace
431 % or extend the data in the |/Info| dictionary.
432 % In PDF 2.0 the /Info dictionary is actually deprecated
433 % and only XMP-metadata should be used for the metadata of the PDF.
434 %
435 % The content of a XMP-metadata stream is not a fix set of data.
436 % Typically fields like the title, the author, the language and keywords will
437 % be there. But standards like e.g. ZUGferd (a standard for electronic bills)
438 % can require to add more fields, and it is also possible
439 % to define and add purely local data.
440 %
441 % In some workflows (e.g. if dvips + ghostscript is used)
442 % a XMP-metadata stream with some standard content is added automatically by
443 % the backend, but normally it must be created with code.
444 %
445 % For this task the packages \pkg{hyperxmp}, \pkg{xmpincl} or \pkg{pdfx}
446 % (which uses \pkg{xmpincl})
447 % can be used, but all these packages are not compatible with the
448 % pdfmanagement\footnote{\pkg{hyperxmp} was partly compatible as the pdfmanagement
449 % contained some patches for it, but these patches have now been removed.}.
450 % The following code is meant as replacement for these packages.
451 %
452 % \pkg{hyperxmp} uses |\hypersetup| as user interface to enter the XMP-metadata.
453 % This syntax is also supported by the new code\footnote{with a number of changes which
454 % are discussed in more details below}, so if \pkg{hyperref}
455 % has been loaded, e.g. |pdftitle=xxx| can be used to set the title.
456 % But XMP-metadata shouldn't require to use \pkg{hyperref} and in a future
457 % version an interface without \pkg{hyperref} will be added.
458 %
459 % There is currently no full user interface command to extend the XMP-metadata
460 % with for example the code needed for ZUGferd,
461 % they will be added in a second step.
462 %
463 % \subsection{Debug option}
464 %
465 % The resulting XMP-packet can be written to an external file by activating a debug
466 % option
467 %
468 % \begin{verbatim}
469 % \DocumentMetadata{debug={xmp-export}}
470 % %or
471 % \DocumentMetadata{debug={xmp-export=true}}
472 % %or
473 % \DocumentMetadata{debug={xmp-export=filename}}
474 % %or
475 % \SetKeys[document/metadata]{debug={xmp-export}}
476 % \end{verbatim}
477 %
478 % By default the data are written to \verb+\jobname.xmpi+, if a \texttt{filename} is
479 % given, then \verb+filename.xmpi+ is used instead. \verb+xmp-export=false+ deactivates
480 % the export.
481 %
482 % \subsection{Encoding and escaping}
483 %
484 % XMP-metadata are stored as UTF-8 in the PDF. This mean if you open a PDF in an editor
485 % a content like \enquote{grüße} will be shown probably as \enquote{grüße}.
486 % As XMP-metadata are in XML format special chars like |<|, |>|, and |&| and
487 % \texttt{\textquotestraightdblbase} must be escaped.
488 %
489 % \pkg{hyperxmp} hooks into \pkg{hyperref} and passes all
490 % input through |\pdfstringdef|. This means a word like
491 % \enquote{hallo} is first converted by |\pdfstringdef| into\\
492 % |\376\377\000h\000a\000l\000l\000o| and then back to UTF-8 by
493 % \pkg{hyperxmp} and in the course of this action
494 % the XML-escapings are applied.
495 % \pkg{pdfx} uses |\pdfstringdef| together with
496 % a special fontencoding (similar to the PU-encoding of \pkg{hyperref})
497 % for a similar aim.
498 % The code here is based on |\text_purify:n| followed by a few replacements for the
499 % escaping.
500 %
501 % User data should normally be declared in the preamble (or even in the
502 % |\DocumentMetadata| command), and consist of rather simple text; |&| can be entered
503 % as |\&| (but directly |&| will normally work too),
504 % babel shorthands should not be used. Some data are interpreted as comma lists,
505 % in this cases commas which are part of the text should be protected by braces.
506 % In some cases a text in brackets like |[en]| is interpreted as language tag,
507 % if they are part of a text they should be protected by braces too.
508 % XMP-metadata are stored uncompressed in the PDF so if you are unsure
509 % if a value has
510 % been passed correctly, open the PDF in an editor, copy the whole block and
511 % pass it to a validator, e.g. \url{https://www.w3.org/RDF/Validator/}.
512 %
513 % \subsection{User interfaces and differences to \pkg{hyperxmp} }
514 %
515 % \subsubsection{PDF standards}
516 %
517 % The \pkg{hyperxmp}/\pkg{hyperref} keys |pdfapart|, |pdfaconformance|, |pdfuapart|,
518 % |pdfxstandard| and |pdfa| are ignored by this code. Standards must be set with the
519 % |pdfstandard| key of |\DocumentMetadata| or |\SetKeys[document/metadata]|.
520 % This key can be used more than once,
521 % e.g. \\
522 % |pdfstandard=A-2b,pdfstandard=X-4,pdfstandard=UA-1|.
523 % \\ Note that using these
524 % keys doesn't mean that the document actually follows the standard. \LaTeX{}
525 % can neither ensure nor check all requirements of a standard, and not everything
526 % it can do theoretically has already been implemented.
527 % When setting an |A| standard, the code will e.g. insert a color profile and
528 % warn if the PDF version doesn't fit, but |X| and |UA| currently only
529 % adds the relevant declarations to the XMP-metadata.
530 % It is up to the author to ensure and validate
531 % that the document actually follows the standard.
532 %
533 % \subsubsection{Declarations}
534 % PDF knows beside standards also a more generic method to declare conformance
535 % to some specification by adding a declaration,
536 % see \url{https://pdfa.org/wp-content/uploads/2019/09/PDF-Declarations.pdf}).
537 % Such declarations can be added as a simple url which identify the specification or
538 % with additional details regarding date and credentials. An example would be
539 %
540 % \begin{verbatim}
541 % \RequirePackage{pdfmanagement} %or \DocumentMetadata{...}
542 % \documentclass{article}
543 % \ExplSyntaxOn
544 % \pdfmeta_xmp_add_declaration:e {https://pdfa.org/declarations\c_hash_str iso32005}
545 % \pdfmeta_xmp_add_declaration:ennnn
546 % {https://pdfa.org/declarations\c_hash_str wcag21A}{}{2023-11-20}{}{}
547 % \pdfmeta_xmp_add_declaration:nnnnn
548 % {https://github.com/TikZlings/no-duck-harmed}
549 % {Ulrike~Fischer}{2023-11-20}{Bär}{https://github.com/u-fischer/bearwear}
550 % \pdfmeta_xmp_add_declaration:nnnnn
551 % {https://github.com/TikZlings/no-duck-harmed}
552 % {Ulrike~Fischer}{2023-11-20}{Paulo}{https://github.com/cereda/sillypage}
553 % \ExplSyntaxOff
554 % \begin{document}
555 % text
556 % \end{document}
557 %
558 % \end{verbatim}
559 %
560 % \subsubsection{Dates}
561 % \begin{itemize}
562 % \item
563 % The dates |xmp:CreateDate|, |xmp:ModifyDate|, |xmp:MetadataDate|
564 % are normally set automatically to the current date/time when the compilation
565 % started. If they should be changed
566 % (e.g. for regression tests to produce reproducible documents) they can
567 % be set with |\hypersetup| with the keys
568 % |pdfcreationdate|, |pdfmoddate| and |pdfmetadate|.
569 %
570 % \begin{verbatim}
571 % \hypersetup{pdfcreationdate=D:20010101205959-00'00'}
572 % \end{verbatim}
573 %
574 % The format should be a full date/time in PDF format, so one of these (naturally
575 % the numbers can change):
576 % \begin{verbatim}
577 % D:20010101205959-00'00'
578 % D:20010101205959+00'00'
579 % D:20010101205959Z
580 % \end{verbatim}
581 %
582 % \item The date |dc:date| is an \enquote{author date} and so
583 % should normally be set to the same date as
584 % given by |\date|. This can be done with the key |pdfdate|\footnote{Extracting
585 % the value automatically from \texttt{\textbackslash date} is not really possible
586 % as authors often put formatting or additional info in this command.}.
587 % The value should be a date in ISO 8601 format:
588 %
589 % \begin{verbatim}
590 % 2022 %year
591 % 2022-09-04 %year-month-day
592 % 2022-09-04T19:20 %year-month-day hour:minutes
593 % 2022-09-04T19:20:30 % year-month-day hour:minutes:second
594 % 2022-09-04T19:20:30.45 % year-month-day hour:minutes:second with fraction
595 % 2022-09-04T19:20+01:00 % with time zone designator
596 % 2022-09-04T19:20-02:00 % time zone designator
597 % 2022-09-04T19:20Z % time zone designator
598 % \end{verbatim}
599 %
600 % It is also possible to give the date as a full date in PDF format as described
601 % above. If not set the current date/time is used.
602 %\end{itemize}
603 %
604 % \subsection{Language}
605 % The code assumes that a default language is always declared
606 % (as the pdfmanagement gives the |/Lang| entry in the catalog a default value)
607 % This language can be changed with the key |lang| of |\DocumentMetadata| and |\SetKeys[document/metadata]|.
608 % This is the preferred method. \pkg{babel} will look for this value and
609 % adjust its language settings.
610 % The \pkg{hyperref} key |pdflang| is also honored. Its value should be a
611 % simple language tag like |de| or |de-DE|.
612 %
613 % The main language is also used in a number of attributes in the XMP data,
614 % if wanted a different language can be set here with the
615 % \pkg{hyperref}/\pkg{hyperxmp} key |pdfmetalang|.
616 %
617 % A number of entries can be given a language tag. Such a language is
618 % given by using an \enquote{optional argument} before the text:
619 %
620 % \begin{verbatim}
621 % \hypersetup{pdftitle={[en]english,[de]deutsch}}
622 % \hypersetup{pdfsubtitle={[en]subtitle in english}}
623 % \end{verbatim}
624 %
625 % \subsection{Rights}
626 % The keys |pdfcopyright| and |pdflicenseurl| work similar as in \pkg{hyperxmp}.
627 % But differently to \pkg{hyperxmp} the code doesn't set the |xmpRights:Marked|
628 % property, as I have some doubts that one deduce its value simply
629 % by checking if the other keys have been used; if needed it can be added by
630 % using one of these settings (true means with copyright, false means public domain).
631 % \begin{verbatim}
632 % \AddToDocumentProperties[document]{copyright}{true}
633 % \AddToDocumentProperties[document]{copyright}{false}
634 % \end{verbatim}
635 %
636 % \subsection{PDF related data}
637 % The PDF producer is for all engines by default built from the engine
638 % name and the engine version and doesn't use the banners as with \pkg{hyperxmp}
639 % and \pkg{pdfx}, it can be set manually with the |pdfproducer| key.
640 %
641 % The key |pdftrapped| is ignored. |Trapped| is deprecated in PDF 2.0.
642 %
643 % \subsection{Document data}
644 %
645 % The authors should be given with the |pdfauthor| key, separated by commas. If an
646 % author contains a comma, protect/hide it by a brace.
647
648 % \subsection{User commands}
649 % The XMP-meta data are added automatically. This can be suppressed with the
650 % |document/metadata| key |xmp|.
651 %
652 % \begin{function}{\pdfmeta_xmp_add:n}
653 % \begin{syntax}
654 % \cs{pdfmeta_xmp_add:n} \Arg{XML}
655 % \end{syntax}
656 % With this command additional XML code can be added to the Metadata.
657 % The content is added unchanged, and not sanitized.
658 % \end{function}
659 % \begin{function}{\pdfmeta_xmp_xmlns_new:nn}
660 % \begin{syntax}
661 % \cs{pdfmeta_xmp_xmlns_new:nn} \Arg{prefix} \Arg{uri}
662 % \end{syntax}
663 % With this command a xmlns name space can be added. The \meta{uri}
664 % argument is expanded, a hash can be input with |\c_hash_str|.
665 % \end{function}
666 %
667 % With the two following commands PDF declarations can be added to the XMP metadata
668 % (see \url{https://pdfa.org/wp-content/uploads/2019/09/PDF-Declarations.pdf}).
669 % \begin{function}{\pdfmeta_xmp_add_declaration:n,\pdfmeta_xmp_add_declaration:e}
670 % \begin{syntax}
671 % \cs{pdfmeta_xmp_add_declaration:n} \Arg{uri}
672 % \end{syntax}
673 % This add a PDF declaration with the required |conformsTo| property to the XMP metadata.
674 % \meta{uri} should not be empty and is a URI specifying
675 % the standard or profile referred to by the PDF
676 % Declaration. If the uri contains a hash, use \cs{c_hash_str} to escape it
677 % and use the \texttt{e} variant to expand it.
678 % \end{function}
679 %
680 % \begin{function}{\pdfmeta_xmp_add_declaration:nnnnn,
681 % \pdfmeta_xmp_add_declaration:ennnn,
682 % \pdfmeta_xmp_add_declaration:eeenn}
683 % \begin{syntax}
684 % \cs{pdfmeta_xmp_add_declaration:nnnnn} \\
685 % ~~~~\Arg{uri} \Arg{By} \Arg{Date} \Arg{Credentials} \Arg{Report}
686 % \end{syntax}
687 % This add a PDF declaration to the XMP metadata similar
688 % to \cs{pdfmeta_xmp_add_declaration:n}.
689 % With \meta{By}, \meta{Date}, \meta{Credentials}, \meta{Report} the optional
690 % fields |claimBy| (text), |claimDate| (iso date), |claimCredentials| (text) and
691 % |claimReport| (uri) of the |claimData| property can be given.
692 % If \cs{pdfmeta_xmp_add_declaration:nnnnn} is used twice with the same \meta{uri}
693 % argument the |claimData| are concatenated. There is no check if the |claimData| are identical.
694 % \end{function}
695 %
696 % The following two commands can be used to extend the schema declarations in
697 % the XMP metadata. This is for example needed to implement a standard like ZUGferd/Factur X
698 % for invoices. A schema declaration should be added only once but as this task
699 % is probably not needed frequently only light guards are there to avoid duplicated entries.
700 %
701 % \begin{function}{\pdfmeta_xmp_schema_new:nnn}
702 % \begin{syntax}
703 % \cs{pdfmeta_xmp_schema_new:nnn} \Arg{text} \Arg{prefix} \Arg{uri}
704 % \end{syntax}
705 % \meta{text} is some string describing the schema, e.g. |PDF/A~Identification~Schema|,
706 % \meta{prefix} is the unique prefix used by the schema. This prefix
707 % must be declared first with |\pdfmeta_xmp_xmlns_new:nn|. If a schema with this prefix
708 % has already been declared, it will currently be ignored with a warning.
709 % The \meta{uri} is expanded, so a
710 % hash can for example be given as |\c_hash_str|.
711 % \end{function}
712
713 % \begin{function}{\pdfmeta_xmp_property_new:nnnnn}
714 % \begin{syntax}
715 % \cs{pdfmeta_xmp_property_new:nnnnn} \Arg{schema prefix} \\
716 % ~~~~\Arg{name} \Arg{type} \Arg{category} \Arg{description}
717 % \end{syntax}
718 % If the new property already exists in the schema
719 % (as identified by the combination of \meta{schema prefix}
720 % and \meta{name} the property is silently ignore.
721 % \meta{schema prefix} is the prefix declared with the previous command.
722 % schema, e.g. |PDF/A~Identification~Schema|,
723 % \meta{name} is a short string that identifies the property, e.g. |xmpMM| or |year|. It must be
724 % unique in the properties of a schema. \meta{type} is e.g. |URI| or |Integer| or |Text|,
725 % \meta{category} is e.g. |internal| or |external|, \meta{description} is a free description string.
726 % \end{function}
727 %
728 % \end{documentation}
729 %
730 % \begin{implementation}
731 %
732 % \section{\pkg{l3pdfmeta} implementation}
733 %
734 % \begin{macrocode}
735 %<@@=pdfmeta>
736 %<*header>
737 \ProvidesExplPackage{l3pdfmeta}{2026-05-26}{0.97c}
738 {PDF-Standards---LaTeX PDF management bundle}
739 %</header>
740 % \end{macrocode}
741 % Message for unknown standards
742 % \begin{macrocode}
743 %<*package>
744 \msg_new:nnn {pdf }{unknown-standard}{The~standard~'#1'~is~unknown~and~has~been~ignored}
745 % \end{macrocode}
746 % Message for unknown standard family
747 % \begin{macrocode}
748 %<*package>
749 \msg_new:nnn {pdf }{unknown-standard-family}{The~standard~family~'#1'~is~unknown}
750 % \end{macrocode}
751 % Message for not fitting pdf version
752 % \begin{macrocode}
753 \msg_new:nnn {pdf }{wrong-pdfversion}
754 {PDF~version~#1~is~too~#2~for~standard~'#3'.\\
755 Check~if~there~are~conflicting~PDF~standard\\
756 and~PDF~version~settings!}
757 % \end{macrocode}
758 % Messages for embedded files
759 % \begin{macrocode}
760 \msg_new:nnn {pdf }{validation-failure}
761 {
762 PDF~standard~validation~failure.\\
763 #1
764 }
765 % \end{macrocode}
766 %
767 % \begin{variable}{\l_@@_tmpa_tl,\l_@@_tmpb_tl,\l_@@_tmpa_str,
768 % \g_@@tmpa_str,\l_@@_tmpa_seq,\l_@@_tmpb_seq}
769 % \begin{macrocode}
770 \tl_new:N \l_@@_tmpa_tl
771 \tl_new:N \l_@@_tmpb_tl
772 \str_new:N \l_@@_tmpa_str
773 \str_new:N \g_@@_tmpa_str
774 \seq_new:N \l_@@_tmpa_seq
775 \seq_new:N \l_@@_tmpb_seq
776 % \end{macrocode}
777 % \end{variable}
778 % \subsection{Standards (work in progress)}
779 % \subsubsection{Tools and tests}
780 % These internal properties will contain the active
781 % settings for a standard family. \cs{g_@@_standard_prop}
782 % will be used to contain the requirements of the current family for a validation.
783 % \begin{variable}{\g_@@_standard_prop,
784 % \g_@@_standard_A_prop,
785 % \g_@@_standard_UA_prop,
786 % \g_@@_standard_X_prop}
787 % \begin{macrocode}
788 \prop_new:N \g_@@_standard_prop
789 \prop_new:N \g_@@_standard_A_prop
790 \prop_new:N \g_@@_standard_UA_prop
791 \prop_new:N \g_@@_standard_X_prop
792 % \end{macrocode}
793 % \end{variable}
794 % \subsubsection{Functions to check a requirement}
795 %
796 % \begin{macro}{\pdfmeta_standard_family:nn}
797 % This allows to run tests for another standard family: it switches the requirements,
798 % executes the code stored in the second argument and then switches back.
799 %
800 % \begin{macrocode}
801 \cs_new_protected:Npn \pdfmeta_standard_family:nn #1 #2
802 {
803 \prop_if_exist:cTF { g_@@_standard_#1_prop }
804 {
805 % \end{macrocode}
806 % until documentmetadata-support is update we can not be sure that
807 % the A prop is properly filled.
808 % \begin{macrocode}
809 \prop_gset_eq:NN \g_@@_standard_A_prop \g_@@_standard_prop
810 \prop_gset_eq:Nc \g_@@_standard_prop { g_@@_standard_#1_prop }
811 #2
812 \prop_gset_eq:NN \g_@@_standard_prop \g_@@_standard_A_prop
813 }
814 {
815 \msg_warning:nnn {pdf} {unknown-standard-family}{#1}
816 }
817 }
818 % \end{macrocode}
819 % \end{macro}
820 %
821 % At first two commands to get the standard value if needed:
822 % \begin{macro}[EXP]{\pdfmeta_standard_item:n}
823 % \begin{macrocode}
824 \cs_new:Npn \pdfmeta_standard_item:n #1
825 {
826 \prop_item:Nn \g_@@_standard_prop {#1}
827 }
828 % \end{macrocode}
829 % \end{macro}
830 % \begin{macro}{\pdfmeta_standard_get:nN}
831 % \begin{macrocode}
832 \cs_new_protected:Npn \pdfmeta_standard_get:nN #1 #2
833 {
834 \prop_get:NnN \g_@@_standard_prop {#1} #2
835 }
836 % \end{macrocode}
837 % \end{macro}
838 % Now two functions to check the requirement. A simple and one value/handler based.
839 % \begin{macro}[pTF]{\pdfmeta_standard_verify:n}
840 % This is a simple test is the requirement is in the prop.
841 % \begin{macrocode}
842 \prg_new_conditional:Npnn \pdfmeta_standard_verify:n #1 {T,F,TF}
843 {
844 \prop_if_in:NnTF \g_@@_standard_prop {#1}
845 {
846 \prg_return_false:
847 }
848 {
849 \prg_return_true:
850 }
851 }
852 % \end{macrocode}
853 % \end{macro}
854 % \begin{macro}[TF]{\pdfmeta_standard_verify:nn}
855 % This allows to test against a user value. It calls a test handler if this
856 % exists and passes the user and the standard value to it. The test
857 % handler should return true or false.
858 % \begin{macrocode}
859 \prg_new_protected_conditional:Npnn \pdfmeta_standard_verify:nn #1 #2 {T,F,TF}
860 {
861 \prop_if_in:NnTF \g_@@_standard_prop {#1}
862 {
863 \cs_if_exist:cTF {@@_standard_verify_handler_#1:nn}
864 {
865 \exp_args:Nnne
866 \use:c
867 {@@_standard_verify_handler_#1:nn}
868 { #2 }
869 { \prop_item:Nn \g_@@_standard_prop {#1} }
870 }
871 {
872 \prg_return_false:
873 }
874 }
875 {
876 \prg_return_true:
877 }
878 }
879 % \end{macrocode}
880 % \end{macro}
881 %
882 % Now we setup a number of handlers.
883 %
884 % The first actually ignores the user values and tests against the
885 % current pdf version. If this is smaller than the minimum we report a failure.
886 % |#1| is the user value, |#2| the reference value from the standard.
887 % \begin{macro}{\@@_standard_verify_handler_min_pdf_version:nn}
888 % \begin{macrocode}
889 %
890 \cs_new_protected:Npn \@@_standard_verify_handler_min_pdf_version:nn #1 #2
891 {
892 \pdf_version_compare:NnTF <
893 { #2 }
894 {\prg_return_false:}
895 {\prg_return_true:}
896 }
897 % \end{macrocode}
898 % \end{macro}
899 % The next is the counter part and checks that the version is not to high
900 % \begin{macro}{\@@_standard_verify_handler_max_pdf_version:nn}
901 % \begin{macrocode}
902 %
903 \cs_new_protected:Npn \@@_standard_verify_handler_max_pdf_version:nn #1 #2
904 {
905 \pdf_version_compare:NnTF >
906 { #2 }
907 {\prg_return_false:}
908 {\prg_return_true:}
909 }
910 % \end{macrocode}
911 % \end{macro}
912 % The next checks if the user value is in the list and returns a failure if not.
913 % \begin{macro}{\@@_standard_verify_handler_named_actions:nn}
914 % \begin{macrocode}
915
916 \cs_new_protected:Npn \@@_standard_verify_handler_named_actions:nn #1 #2
917 {
918 \tl_if_in:nnTF { #2 }{ #1 }
919 {\prg_return_true:}
920 {\prg_return_false:}
921 }
922 % \end{macrocode}
923 % \end{macro}
924 % The next checks if the user value is in the list and returns a failure if not.
925 % \begin{macro}{\@@_standard_verify_handler_annot_action_A:nn}
926 % \begin{macrocode}
927 \cs_new_protected:Npn \@@_standard_verify_handler_annot_action_A:nn #1 #2
928 {
929 \tl_if_in:nnTF { #2 }{ #1 }
930 {\prg_return_true:}
931 {\prg_return_false:}
932 }
933 % \end{macrocode}
934 % \end{macro}
935 % This check is probably not needed, but for completeness
936 % \begin{macro}{\@@_standard_verify_handler_outputintent_subtype:nn}
937 % \begin{macrocode}
938 \cs_new_protected:Npn \@@_standard_verify_handler_outputintent_subtype:nn #1 #2
939 {
940 \tl_if_eq:nnTF { #2 }{ #1 }
941 {\prg_return_true:}
942 {\prg_return_false:}
943 }
944 % \end{macrocode}
945 % \end{macro}
946 % \subsubsection{Enforcing requirements}
947 % A number of requirements can sensibly be enforced by us.
948 % \paragraph{Annot flags}
949 % pdf/A require a number of settings here, we store them in a command which
950 % can be added to the property of the standard:
951 % \begin{macrocode}
952 \cs_new_protected:Npn \@@_verify_pdfa_annot_flags:
953 {
954 \bitset_set_true:Nn \l_pdfannot_F_bitset {Print}
955 \bitset_set_false:Nn \l_pdfannot_F_bitset {Hidden}
956 \bitset_set_false:Nn \l_pdfannot_F_bitset {Invisible}
957 \bitset_set_false:Nn \l_pdfannot_F_bitset {NoView}
958 \pdfannot_dict_put:nnn {link/URI}{F}{ \bitset_to_arabic:N \l_pdfannot_F_bitset }
959 \pdfannot_dict_put:nnn {link/GoTo}{F}{ \bitset_to_arabic:N \l_pdfannot_F_bitset }
960 \pdfannot_dict_put:nnn {link/GoToR}{F}{ \bitset_to_arabic:N \l_pdfannot_F_bitset }
961 \pdfannot_dict_put:nnn {link/Launch}{F}{ \bitset_to_arabic:N \l_pdfannot_F_bitset }
962 \pdfannot_dict_put:nnn {link/Named}{F}{ \bitset_to_arabic:N \l_pdfannot_F_bitset }
963 }
964 % \end{macrocode}
965 % At begin document this should be checked:
966 % \begin{macrocode}
967 \hook_gput_code:nnn {begindocument} {pdf}
968 {
969 \pdfmeta_standard_verify:nF { annot_flags }
970 { \@@_verify_pdfa_annot_flags: }
971 \pdfmeta_standard_verify:nF { Trailer_no_Info }
972 { \__pdf_backend_omit_info:n {1} }
973 \pdfmeta_standard_verify:nF { no_CharSet }
974 { \__pdf_backend_omit_charset:n {1} }
975 \pdfmeta_standard_verify:nF { omit_CID }
976 { \__pdf_backend_omit_cidset:n {1} }
977 \@@_check_standard_pdfversion:
978 }
979 % \end{macrocode}
980 %
981 %
982 % \subsubsection{pdf/A}
983 % We use global properties so that follow up standards can be
984 % copied and then adjusted.
985 % Some note about requirements for more standard can
986 % be found in info/pdfstandard.tex.
987 % \begin{variable}{
988 % \g_@@_standard_pdf/A-1B_prop ,
989 % \g_@@_standard_pdf/A-2A_prop ,
990 % \g_@@_standard_pdf/A-2B_prop ,
991 % \g_@@_standard_pdf/A-2U_prop ,
992 % \g_@@_standard_pdf/A-3A_prop ,
993 % \g_@@_standard_pdf/A-3B_prop ,
994 % \g_@@_standard_pdf/A-3U_prop ,
995 % \g_@@_standard_pdf/A-4_prop ,
996 % \g_@@_standard_pdf/A-4F_prop ,
997 % \g_@@_standard_pdf/A-4E_prop ,
998 % }
999 % \begin{macrocode}
1000 \prop_new:c { g_@@_standard_pdf/A-1B_prop }
1001 \prop_gset_from_keyval:cn { g_@@_standard_pdf/A-1B_prop }
1002 {
1003 ,name = pdf/A-1B
1004 ,type = A
1005 ,level = 1
1006 ,conformance = B
1007 ,year = 2005
1008 ,min_pdf_version = 1.4 %minimum
1009 ,max_pdf_version = 1.4 %maximum
1010 ,no_encryption =
1011 ,no_external_content = % no F, FFilter, or FDecodeParms in stream dicts
1012 ,no_embed_content = % no EF key in filespec, no /Type/EmbeddedFiles
1013 ,max_string_size = 65535
1014 ,max_array_size = 8191
1015 ,max_dict_size = 4095
1016 ,max_obj_num = 8388607
1017 ,max_nest_qQ = 28
1018 ,named_actions = {NextPage, PrevPage, FirstPage, LastPage}
1019 ,annot_flags =
1020 %booleans. Only the existence of the key matter.
1021 %If the entry is added it means a requirements is there
1022 %(in most cases "don't use ...")
1023 %
1024 %===============
1025 % Rule 6.1.13-1 CosDocument, isOptionalContentPresent == false
1026 ,Catalog_no_OCProperties =
1027 % Rule 6.9-4 The AS key shall not appear in any optional content configuration dictionary.
1028 % actually only starting with A-2 but doesn't harm here either
1029 ,Catalog_OCProperties_no_AS=
1030 %===============
1031 % Rule 6.6.1-1: PDAction, S == "GoTo" || S == "GoToR" || S == "Thread"
1032 % || S == "URI" || S == "Named" || S == "SubmitForm"
1033 % means: no /S/Launch, /S/Sound, /S/Movie, /S/ResetForm, /S/ImportData,
1034 % /S/JavaScript, /S/Hide
1035 ,annot_action_A = {GoTo,GoToR,Thread,URI,Named,SubmitForm}
1036 %===============
1037 % Rule 6.6.2-1: PDAnnot, Subtype != "Widget" || AA_size == 0
1038 % means: no AA dictionary
1039 ,annot_widget_no_AA =
1040 %===============
1041 % Rule 6.9-2: PDAnnot, Subtype != "Widget" || (A_size == 0 && AA_size == 0)
1042 % (looks like a tightening of the previous rule)
1043 ,annot_widget_no_A_AA =
1044 %===============
1045 % Rule 6.9-1 PDAcroForm, NeedAppearances == null || NeedAppearances == false
1046 ,form_no_NeedAppearances =
1047 %===============
1048 %Rule 6.9-3 PDFormField, AA_size == 0
1049 ,form_no_AA =
1050 %===============
1051 % to be continued https://docs.verapdf.org/validation/pdfa-part1/
1052 % - Outputintent/colorprofiles requirements
1053 % an outputintent should be loaded and is unique.
1054 ,outputintent_A = {GTS_PDFA1}
1055 % - no Alternates key in image dictionaries
1056 % - no OPI, Ref, Subtype2 with PS key in xobjects
1057 % - Interpolate = false in images
1058 % - no TR, TR2 in ExtGstate
1059 }
1060
1061 %A-2b ==============
1062 \prop_new:c { g_@@_standard_pdf/A-2B_prop }
1063 \prop_gset_eq:cc
1064 { g_@@_standard_pdf/A-2B_prop }
1065 { g_@@_standard_pdf/A-1B_prop }
1066 \prop_gput:cnn
1067 { g_@@_standard_pdf/A-2B_prop }{name}{pdf/A-2B}
1068 \prop_gput:cnn
1069 { g_@@_standard_pdf/A-2B_prop }{year}{2011}
1070 \prop_gput:cnn
1071 { g_@@_standard_pdf/A-2B_prop }{level}{2}
1072 % embedding files is allowed (with restrictions)
1073 \prop_gremove:cn
1074 { g_@@_standard_pdf/A-2B_prop }
1075 { no_embed_content }
1076 \prop_gput:cnn
1077 { g_@@_standard_pdf/A-2B_prop }
1078 { only_pdfa_embed_content }
1079 {}
1080 \prop_gput:cnn
1081 { g_@@_standard_pdf/A-2B_prop }{max_pdf_version}{1.7}
1082 \prop_gput:cnn
1083 { g_@@_standard_pdf/A-2B_prop }{omit_CID}{}
1084 % OCG layers are allowed (with restrictions)
1085 \prop_gremove:cn
1086 { g_@@_standard_pdf/A-2B_prop }
1087 { Catalog_no_OCProperties }
1088
1089 %A-2u ==============
1090 \prop_new:c { g_@@_standard_pdf/A-2U_prop }
1091 \prop_gset_eq:cc
1092 { g_@@_standard_pdf/A-2U_prop }
1093 { g_@@_standard_pdf/A-2B_prop }
1094 \prop_gput:cnn
1095 { g_@@_standard_pdf/A-2U_prop }{name}{pdf/A-2U}
1096 \prop_gput:cnn
1097 { g_@@_standard_pdf/A-2U_prop }{conformance}{U}
1098 \prop_gput:cnn
1099 { g_@@_standard_pdf/A-2U_prop }{unicode}{}
1100
1101 %A-2a ==============
1102 \prop_new:c { g_@@_standard_pdf/A-2A_prop }
1103 \prop_gset_eq:cc
1104 { g_@@_standard_pdf/A-2A_prop }
1105 { g_@@_standard_pdf/A-2B_prop }
1106 \prop_gput:cnn
1107 { g_@@_standard_pdf/A-2A_prop }{name}{pdf/A-2A}
1108 \prop_gput:cnn
1109 { g_@@_standard_pdf/A-2A_prop }{conformance}{A}
1110 \prop_gput:cnn
1111 { g_@@_standard_pdf/A-2A_prop }{tagged}{}
1112
1113
1114 %A-3b ==============
1115 \prop_new:c { g_@@_standard_pdf/A-3B_prop }
1116 \prop_gset_eq:cc
1117 { g_@@_standard_pdf/A-3B_prop }
1118 { g_@@_standard_pdf/A-2B_prop }
1119 \prop_gput:cnn
1120 { g_@@_standard_pdf/A-3B_prop }{name}{pdf/A-3B}
1121 \prop_gput:cnn
1122 { g_@@_standard_pdf/A-3B_prop }{year}{2012}
1123 \prop_gput:cnn
1124 { g_@@_standard_pdf/A-3B_prop }{level}{3}
1125 % embedding files is allowed
1126 \prop_gremove:cn
1127 { g_@@_standard_pdf/A-3B_prop }
1128 { only_pdfa_embed_content }
1129 %A-3u ==============
1130 \prop_new:c { g_@@_standard_pdf/A-3U_prop }
1131 \prop_gset_eq:cc
1132 { g_@@_standard_pdf/A-3U_prop }
1133 { g_@@_standard_pdf/A-3B_prop }
1134 \prop_gput:cnn
1135 { g_@@_standard_pdf/A-3U_prop }{name}{pdf/A-3U}
1136 \prop_gput:cnn
1137 { g_@@_standard_pdf/A-3U_prop }{conformance}{U}
1138 \prop_gput:cnn
1139 { g_@@_standard_pdf/A-3U_prop }{unicode}{}
1140
1141 %A-3a ==============
1142 \prop_new:c { g_@@_standard_pdf/A-3A_prop }
1143 \prop_gset_eq:cc
1144 { g_@@_standard_pdf/A-3A_prop }
1145 { g_@@_standard_pdf/A-3B_prop }
1146 \prop_gput:cnn
1147 { g_@@_standard_pdf/A-3A_prop }{name}{pdf/A-3A}
1148 \prop_gput:cnn
1149 { g_@@_standard_pdf/A-3A_prop }{conformance}{A}
1150 \prop_gput:cnn
1151 { g_@@_standard_pdf/A-3A_prop }{tagged}{}
1152
1153 %A-4 ==============
1154 \prop_new:c { g_@@_standard_pdf/A-4_prop }
1155 \prop_gset_eq:cc
1156 { g_@@_standard_pdf/A-4_prop }
1157 { g_@@_standard_pdf/A-3U_prop }
1158 \prop_gput:cnn
1159 { g_@@_standard_pdf/A-4_prop }{name}{pdf/A-4}
1160 \prop_gput:cnn
1161 { g_@@_standard_pdf/A-4_prop }{level}{4}
1162 \prop_gput:cnn
1163 { g_@@_standard_pdf/A-4_prop }{min_pdf_version}{2.0}
1164 \prop_gput:cnn
1165 { g_@@_standard_pdf/A-4_prop }{year}{2020}
1166 \prop_gput:cnn
1167 { g_@@_standard_pdf/A-4_prop }{no_CharSet}{}
1168 \prop_gput:cnn
1169 { g_@@_standard_pdf/A-4_prop }{Trailer_no_Info}{}
1170 \prop_gput:cnn
1171 { g_@@_standard_pdf/A-4_prop }{only_pdfa_embed_content}{}
1172 \prop_gremove:cn
1173 { g_@@_standard_pdf/A-4_prop }{conformance}
1174 \prop_gremove:cn
1175 { g_@@_standard_pdf/A-4_prop }{max_pdf_version}
1176 \prop_gremove:cn
1177 { g_@@_standard_pdf/A-4_prop }{Catalog_OCProperties_no_AS}
1178 %A-4f ==============
1179 \prop_new:c { g_@@_standard_pdf/A-4F_prop }
1180 \prop_gset_eq:cc
1181 { g_@@_standard_pdf/A-4F_prop }
1182 { g_@@_standard_pdf/A-4_prop }
1183 \prop_gput:cnn
1184 { g_@@_standard_pdf/A-4F_prop }{conformance}{F}
1185 % containsEmbeddedFiles == true ISO 19005-4:2020, Clause: 6.9, Test number: 5
1186 \prop_gput:cnn
1187 { g_@@_standard_pdf/A-4F_prop }{Catalog_EmbeddedFiles}{}
1188 % can contain any file
1189 \prop_gremove:cn
1190 { g_@@_standard_pdf/A-4F_prop }{only_pdfa_embed_content}
1191 %A-4e ==============
1192 \prop_new:c { g_@@_standard_pdf/A-4E_prop }
1193 \prop_gset_eq:cc
1194 { g_@@_standard_pdf/A-4E_prop }
1195 { g_@@_standard_pdf/A-4_prop }
1196 \prop_gput:cnn
1197 { g_@@_standard_pdf/A-4E_prop }{conformance}{E}
1198 % \end{macrocode}
1199 % \end{variable}
1200 %
1201 % \subsubsection{pdf/UA}
1202 % \begin{variable}{
1203 % \g_@@_standard_pdf/UA-1_prop ,
1204 % \g_@@_standard_pdf/UA-2_prop ,
1205 % }
1206 % \begin{macrocode}
1207 \prop_new:c { g_@@_standard_pdf/UA-1_prop}
1208 \prop_new:c { g_@@_standard_pdf/UA-2_prop}
1209 \prop_gset_from_keyval:cn { g_@@_standard_pdf/UA-1_prop }
1210 {
1211 ,name = pdf/UA-1
1212 ,level = 1
1213 ,year = 2014
1214 ,min_pdf_version = 1.4 %minimum
1215 ,max_pdf_version = 1.7 %maximum
1216 ,tagged =
1217 ,link_Contents =
1218 }
1219 \prop_gset_from_keyval:cn { g_@@_standard_pdf/UA-2_prop }
1220 {
1221 ,name = pdf/UA-2
1222 ,level = 2
1223 ,year = 2024
1224 ,min_pdf_version = 2.0 %minimum
1225 ,tagged =
1226 }
1227 % \end{macrocode}
1228 % \end{variable}
1229 %
1230 % \subsubsection{pdf/X}
1231 % We know only the names \ldots
1232 % \begin{variable}{
1233 % \g_@@_standard_pdf/X-4_prop ,
1234 % \g_@@_standard_pdf/X-4P_prop,
1235 % \g_@@_standard_pdf/X-5G_prop,
1236 % \g_@@_standard_pdf/X-5N_prop,
1237 % \g_@@_standard_pdf/X-5PG_prop,
1238 % \g_@@_standard_pdf/X-6_prop,
1239 % \g_@@_standard_pdf/X-6N_prop,
1240 % \g_@@_standard_pdf/X-6P_prop,
1241 % }
1242 % \begin{macrocode}
1243 \prop_new:c { g_@@_standard_pdf/X-4_prop}
1244 \prop_new:c { g_@@_standard_pdf/X-4P_prop}
1245 \prop_new:c { g_@@_standard_pdf/X-5G_prop}
1246 \prop_new:c { g_@@_standard_pdf/X-5N_prop}
1247 \prop_new:c { g_@@_standard_pdf/X-5PG_prop}
1248 \prop_new:c { g_@@_standard_pdf/X-6_prop}
1249 \prop_new:c { g_@@_standard_pdf/X-6N_prop}
1250 \prop_new:c { g_@@_standard_pdf/X-6P_prop}
1251
1252 \prop_gset_from_keyval:cn { g_@@_standard_pdf/X-4_prop }
1253 {
1254 ,name = PDF/X-4
1255 }
1256 \prop_gset_from_keyval:cn { g_@@_standard_pdf/X-4P_prop }
1257 {
1258 ,name = PDF/X-4p
1259 }
1260 \prop_gset_from_keyval:cn { g_@@_standard_pdf/X-5G_prop }
1261 {
1262 ,name = PDF/X-5g
1263 }
1264 \prop_gset_from_keyval:cn { g_@@_standard_pdf/X-5N_prop }
1265 {
1266 ,name = PDF/X-5n
1267 }
1268 \prop_gset_from_keyval:cn { g_@@_standard_pdf/X-5PG_prop }
1269 {
1270 ,name = PDF/X-5pg
1271 }
1272 \prop_gset_from_keyval:cn { g_@@_standard_pdf/X-6_prop }
1273 {
1274 ,name = PDF/X-6
1275 }
1276 \prop_gset_from_keyval:cn { g_@@_standard_pdf/X-6N_prop }
1277 {
1278 ,name = PDF/X-6n
1279 }
1280 \prop_gset_from_keyval:cn { g_@@_standard_pdf/X-6P_prop }
1281 {
1282 ,name = PDF/X-6p
1283 }
1284 % \end{macrocode}
1285 % \end{variable}
1286 %
1287 % \subsubsection{Embedded Files}
1288 % Standard 4-AF is needed if we add AF files for
1289 % tagging but it also requires an EmbeddedFiles name tree,
1290 % so we test at the end if the name tree is empty and add a small readme if
1291 % yes
1292 % \begin{macrocode}
1293 \AddToHook{begindocument/end}
1294 {
1295 \pdfmeta_standard_verify:nF{Catalog_EmbeddedFiles}
1296 {
1297 \tl_gput_right:Nn\g__kernel_pdfmanagement_end_run_code_tl
1298 {
1299 \pdfdict_if_empty:nT { g__pdf_Core/Catalog/Names/EmbeddedFiles }
1300 {
1301 \group_begin:
1302 \pdfdict_put:nne {l_pdffile/Filespec} {Desc}{(note~about~PDF/A-4F)}
1303 \pdfdict_put:nnn { l_pdffile/Filespec }{AFRelationship} { /Unspecified }
1304 \pdffile_embed_stream:nnN
1305 {The~document~was~declared~to~be~of~type~PDF/A-4f~but~hasn't~any~attachments.~
1306 LaTeX~therefore~added~this~dummy~file.}
1307 {pdf-A4f.txt}
1308 \l_@@_tmpa_tl
1309 \exp_args:Nne \__pdf_backend_Names_gpush:nn{EmbeddedFiles}{(pdf-A4f)~\l_@@_tmpa_tl}
1310 \group_end:
1311 }
1312 }
1313 }
1314 }
1315 % \end{macrocode}
1316 % Before writing the xml we check if there are embedded files we know of. For A-4 we adjust
1317 % the standard to A-4F is needed.
1318 % \begin{macrocode}
1319 \AddToHook{enddocument/end}
1320 {
1321 \pdfmeta_standard_verify:nF{no_embed_content}
1322 {
1323 \bool_lazy_or:nnT
1324 { ! \int_if_zero_p:n { \g_pdffile_embed_pdfa_int } }
1325 { ! \int_if_zero_p:n { \g_pdffile_embed_nonpdfa_int } }
1326 {
1327 \prop_get:NnNT\g_@@_standard_prop { name }\l_@@_tmpa_tl
1328 {
1329 \msg_warning:nne { pdf } { validation-failure }
1330 {
1331 Embedded~files~detected.\iow_newline:
1332 This~is~not~allowed~in~standard~\l_@@_tmpa_tl
1333 }
1334 }
1335 }
1336 }
1337 \pdfmeta_standard_verify:nF {only_pdfa_embed_content}
1338 {
1339 \int_if_zero:nF { \g_pdffile_embed_nonpdfa_int }
1340 {
1341 \prop_get:NnNT\g_@@_standard_prop { name }\l_@@_tmpa_tl
1342 {
1343 \str_if_eq:VnTF {\l_@@_tmpa_tl} { pdf/A-4 }
1344 {
1345 \msg_note:nne { pdf } { validation-failure }
1346 {
1347 Embedded~non-PDF~files~detected.\iow_newline:
1348 Check~if~the~standard~must~be~changed~to~PDF/A-4F
1349 }
1350 }
1351 {
1352 \msg_warning:nne { pdf } { validation-failure }
1353 {
1354 Embedded~non-PDF~files~detected.\iow_newline:
1355 This~is~not~allowed~in~standard~\l_@@_tmpa_tl
1356 }
1357 }
1358 }
1359 }
1360 }
1361 }
1362 % \end{macrocode}
1363 %
1364 % \subsubsection{Colorprofiles and Outputintents}
1365 % The following provides a minimum of interface to add a color profile
1366 % and an outputintent need for PDF/A for now. There will be need to extend it later,
1367 % so we try for enough generality.
1368 %
1369 % Adding a profile and an intent is technically easy:
1370 % \begin{enumerate}
1371 % \item Embed the profile as stream with
1372 % \begin{verbatim}
1373 % \pdf_object_unnamed_write:nn{fstream} {{/N~4}{XXX.icc}}
1374 % \end{verbatim}
1375 % \item Write a |/OutputIntent| dictionary for this
1376 % \begin{verbatim}
1377 % \pdf_object_unnamed_write:ne {dict}
1378 % {
1379 % /Type /OutputIntent
1380 % /S /GTS_PDFA1 % or GTS_PDFX or ISO_PDFE1 or ...
1381 % /DestOutputProfile \pdf_object_ref_last: % ref the color profile
1382 % /OutputConditionIdentifier ...
1383 % ... %more info
1384 % }
1385 % \end{verbatim}
1386 % \item Reference the dictionary in the catalog:
1387 % \begin{verbatim}
1388 % \pdfmanagement_add:nne {Catalog}{OutputIntents}{\pdf_object_ref_last:}
1389 % \end{verbatim}
1390 % \end{enumerate}
1391 % But we need to do a bit more work, to get the interface right.
1392 % The object for the profile should be named, to allow l3color to reuse it
1393 % if needed. And we need container to store the profiles, to handle the
1394 % standard requirements.
1395 %
1396 % \begin{variable}{\g_@@_outputintents_prop}
1397 % This variable will hold the profiles for the subtypes. We assume
1398 % that every subtype has only only color profile.
1399 % \begin{macrocode}
1400 \prop_new:N \g_@@_outputintents_prop
1401 % \end{macrocode}
1402 % \end{variable}
1403 % Some keys to fill the property.
1404 % \begin{macrocode}
1405 \keys_define:nn { document / metadata }
1406 {
1407 colorprofiles .code:n =
1408 {
1409 \keys_set:nn { document / metadata / colorprofiles }{#1}
1410 }
1411 }
1412 \keys_define:nn { document / metadata / colorprofiles }
1413 {
1414 ,A .code:n =
1415 {
1416 \tl_if_blank:nF {#1}
1417 {
1418 \prop_gput:Nnn \g_@@_outputintents_prop
1419 { GTS_PDFA1 } {#1}
1420 }
1421 }
1422 ,a .code:n =
1423 {
1424 \tl_if_blank:nF {#1}
1425 {
1426 \prop_gput:Nnn \g_@@_outputintents_prop
1427 { GTS_PDFA1 } {#1}
1428 }
1429 }
1430 ,X .code:n =
1431 {
1432 \tl_if_blank:nF {#1}
1433 {
1434 \prop_gput:Nnn \g_@@_outputintents_prop
1435 { GTS_PDFX } {#1}
1436 }
1437 }
1438 ,x .code:n =
1439 {
1440 \tl_if_blank:nF {#1}
1441 {
1442 \prop_gput:Nnn \g_@@_outputintents_prop
1443 { GTS_PDFX } {#1}
1444 }
1445 }
1446 ,unknown .code:n =
1447 {
1448 \tl_if_blank:nF {#1}
1449 {
1450 \exp_args:NNo
1451 \prop_gput:Nnn \g_@@_outputintents_prop
1452 { \l_keys_key_str } {#1}
1453 }
1454 }
1455 }
1456 % \end{macrocode}
1457 % At first we setup our two default profiles. This is internal as
1458 % the public interface is still undecided.
1459 % \begin{macrocode}
1460 \pdfdict_new:n {l_pdfmeta/outputintent}
1461 \pdfdict_put:nnn {l_pdfmeta/outputintent}
1462 {Type}{/OutputIntent}
1463 \prop_const_from_keyval:cn { c_@@_colorprofile_sRGB.icc}
1464 {
1465 ,OutputConditionIdentifier=IEC~sRGB
1466 ,Info=IEC~61966-2.1~Default~RGB~colour~space~-~sRGB
1467 ,RegistryName=http://www.iec.ch
1468 ,N = 3
1469 }
1470 \prop_const_from_keyval:cn { c_@@_colorprofile_FOGRA39L_coated.icc}
1471 {
1472 ,OutputConditionIdentifier=FOGRA39L~Coated
1473 ,Info={Offset~printing,~according~to~ISO~12647-2:2004/Amd~1,~OFCOM,~ %
1474 paper~type~1~or~2~=~coated~art,~115~g/m2,~tone~value~increase~
1475 curves~A~(CMY)~and~B~(K)}
1476 ,RegistryName=http://www.fogra.org
1477 ,N = 4
1478 }
1479 % \end{macrocode}
1480 % \begin{macro}{\@@_embed_colorprofile:n,\@@_write_outputintent:nn}
1481 % The commands embed the profile, and write the dictionary and add it to
1482 % the catalog. The first command should perhaps be moved to l3color
1483 % as it needs such profiles too. We used named objects so that we can
1484 % check if the profile is already there. This is not foolproof if paths are
1485 % used.
1486 % \begin{macrocode}
1487 \cs_new_protected:Npn \@@_embed_colorprofile:n #1%#1 file name
1488 {
1489 \pdf_object_if_exist:nF { __color_icc_ #1 }
1490 {
1491 \pdf_object_new:n { __color_icc_ #1 }
1492 \pdf_object_write:nne { __color_icc_ #1 } { fstream }
1493 {
1494 {/N\c_space_tl
1495 \prop_item:cn{c_@@_colorprofile_#1}{N}
1496 }
1497 {#1}
1498 }
1499 }
1500 }
1501
1502 \cs_new_protected:Npn \@@_write_outputintent:nn #1 #2 %#1 file name, #2 subtype
1503 {
1504 \group_begin:
1505 \pdfdict_put:nne {l_pdfmeta/outputintent}{S}{/\str_convert_pdfname:n{#2}}
1506 \pdfdict_put:nne {l_pdfmeta/outputintent}
1507 {DestOutputProfile}
1508 {\pdf_object_ref:n{ __color_icc_ #1 }}
1509 \clist_map_inline:nn { OutputConditionIdentifier, Info, RegistryName }
1510 {
1511 \prop_get:cnNT
1512 { c_@@_colorprofile_#1}
1513 { ##1 }
1514 \l_@@_tmpa_tl
1515 {
1516 \pdf_string_from_unicode:nVN {utf8/string}\l_@@_tmpa_tl\l_@@_tmpa_str
1517 \pdfdict_put:nne
1518 {l_pdfmeta/outputintent}{##1}{\l_@@_tmpa_str}
1519 }
1520 }
1521 \pdf_object_unnamed_write:ne {dict}{\pdfdict_use:n {l_pdfmeta/outputintent} }
1522 \pdfmanagement_add:nne {Catalog}{OutputIntents}{\pdf_object_ref_last:}
1523 \group_end:
1524 }
1525 % \end{macrocode}
1526 % \end{macro}
1527 % Now the verifying code.
1528 % If no requirement is set we simply loop over the property
1529 % \begin{macrocode}
1530
1531 \AddToHook{begindocument/end}
1532 {
1533 \pdfmeta_standard_verify:nTF {outputintent_A}
1534 {
1535 \prop_map_inline:Nn \g_@@_outputintents_prop
1536 {
1537 \prop_if_exist:cTF {c_@@_colorprofile_#2}
1538 {
1539 \@@_embed_colorprofile:n
1540 {#2}
1541 \@@_write_outputintent:nn
1542 {#2}
1543 {#1}
1544 }
1545 {
1546 \msg_warning:nnn{pdfmeta}{colorprofile-undefined}{#2}
1547 }
1548 }
1549 }
1550 % \end{macrocode}
1551 % If an output intent is required for pdf/A we need to ensure, that the key of
1552 % default subtype has a value, as default we take sRGB.icc.
1553 % Then we loop but take always the same profile.
1554 % \begin{macrocode}
1555 {
1556 \exp_args:NNe
1557 \prop_if_in:NnF
1558 \g_@@_outputintents_prop
1559 { \pdfmeta_standard_item:n { outputintent_A } }
1560 {
1561 \exp_args:NNe
1562 \prop_gput:Nnn
1563 \g_@@_outputintents_prop
1564 { \pdfmeta_standard_item:n { outputintent_A } }
1565 { sRGB.icc }
1566 }
1567 \exp_args:NNe
1568 \prop_get:NnN
1569 \g_@@_outputintents_prop
1570 { \pdfmeta_standard_item:n { outputintent_A } }
1571 \l_@@_tmpb_tl
1572 \prop_if_exist:cTF {c_@@_colorprofile_\l_@@_tmpb_tl}
1573 {
1574 \exp_args:NV \@@_embed_colorprofile:n \l_@@_tmpb_tl
1575 \prop_map_inline:Nn \g_@@_outputintents_prop
1576 {
1577 \exp_args:NV
1578 \@@_write_outputintent:nn
1579 \l_@@_tmpb_tl
1580 { #1 }
1581 }
1582 }
1583 {
1584 \msg_warning:nne{pdfmeta}{colorprofile-undefined}{\l_@@_tmpb_tl}
1585 }
1586 }
1587 }
1588 % \end{macrocode}
1589 %
1590 % \subsection{Regression test}
1591 % This is simply a copy of the backend function.
1592 % \begin{macrocode}
1593 \cs_new_protected:Npn \pdfmeta_set_regression_data:
1594 { \__pdf_backend_set_regression_data: }
1595 % \end{macrocode}
1596 %
1597 % \section{XMP-Metadata implementation}
1598
1599 % \begin{variable}{\g_@@_xmp_bool}
1600 % This boolean decides if the metadata are included
1601 % \begin{macrocode}
1602 \bool_new:N\g_@@_xmp_bool
1603 \bool_gset_true:N \g_@@_xmp_bool
1604 % \end{macrocode}
1605 % \end{variable}
1606 % Preset the two fields to avoid problems with standards.
1607 % \begin{macrocode}
1608 \hook_gput_code:nnn{pdfmanagement/add}{pdfmanagement}
1609 {
1610 \pdfmanagement_add:nne {Info}{Producer}{(\c_sys_engine_exec_str-\c_sys_engine_version_str)}
1611 \pdfmanagement_add:nne {Info}{Creator}{(LaTeX)}
1612 }
1613 % \end{macrocode}
1614 % \subsection{New document keys}
1615 % \begin{macrocode}
1616 \cs_generate_variant:Nn\pdf_version_gset:n{e}
1617 % \end{macrocode}
1618 % if the pdf version is wrong for the standard we force the highest possible.
1619 % \begin{macrocode}
1620 \cs_new_protected:Nn\@@_force_standard_pdfversion:
1621 {
1622 \pdfmeta_standard_verify:nnF { min_pdf_version }
1623 { \pdf_version: }
1624 {
1625 \pdfmeta_standard_verify:nTF { max_pdf_version }
1626 {
1627 \pdf_version_gset:n { 2.0 }
1628 }
1629 {
1630 \pdf_version_gset:e{ \pdfmeta_standard_item:n{ max_pdf_version } }
1631 }
1632 }
1633 \pdfmeta_standard_verify:nnF { max_pdf_version }
1634 { \pdf_version: }
1635 {
1636 \pdf_version_gset:e{ \pdfmeta_standard_item:n{ max_pdf_version } }
1637 }
1638 }
1639 % \end{macrocode}
1640 % At begin document we then want to test if there is a version problem.
1641 % \begin{macrocode}
1642 \cs_new_protected:Npn \@@_check_standard_pdfversion:
1643 {
1644 \clist_map_inline:nn{A,UA,X}
1645 {
1646 \pdfmeta_standard_family:nn { ##1 }
1647 {
1648 \pdfmeta_standard_verify:nnF { min_pdf_version }
1649 { \pdf_version: }
1650 { \msg_warning:nneee {pdf}{wrong-pdfversion} %TODO make error
1651 {\pdf_version:}{low}
1652 {
1653 \pdfmeta_standard_item:n{name}
1654 }
1655 }
1656 \pdfmeta_standard_verify:nnF { max_pdf_version }
1657 { \pdf_version: }
1658 { \msg_warning:nneee {pdf}{wrong-pdfversion}
1659 {\pdf_version:}{high}
1660 {
1661 \pdfmeta_standard_item:n{name}
1662 }
1663 }
1664 }
1665 }
1666 }
1667 % \end{macrocode}
1668 %
1669 % \begin{macrocode}
1670 \keys_define:nn { document / metadata }
1671 {
1672 _pdfstandard .choices:nn =
1673 {A-1B,A-2A,A-2B,A-2U,A-3A,A-3B,A-3U,A-4,A-4F,A-4E}
1674 {
1675 \prop_gset_eq:Nc \g__pdfmeta_standard_A_prop { g__pdfmeta_standard_pdf/#1 _prop }
1676 \prop_gset_eq:NN \g__pdfmeta_standard_prop \g__pdfmeta_standard_A_prop
1677 \@@_force_standard_pdfversion:
1678 \AddToDocumentProperties [document]{pdfstandard}{#1}
1679 },
1680 _pdfstandard / unknown .code:n =
1681 {
1682 \msg_error:nnn{pdf}{unknown-standard}{#1}
1683 },
1684 _pdfstandard / X-4 .code:n =
1685 {
1686 \prop_gset_eq:Nc \g__pdfmeta_standard_X_prop { g__pdfmeta_standard_pdf/X-4_prop }
1687 \AddToDocumentProperties [document]{pdfstandard-X}{PDF/X-4}
1688 \@@_xmp_add_pdfxid:
1689 },
1690 _pdfstandard / X-4P .code:n =
1691 {
1692 \prop_gset_eq:Nc \g__pdfmeta_standard_X_prop { g__pdfmeta_standard_pdf/X-4P_prop }
1693 \AddToDocumentProperties [document]{pdfstandard-X}{PDF/X-4p}
1694 \@@_xmp_add_pdfxid:
1695 },
1696 _pdfstandard / X-5G .code:n =
1697 {
1698 \prop_gset_eq:Nc \g__pdfmeta_standard_X_prop { g__pdfmeta_standard_pdf/X-5G_prop }
1699 \AddToDocumentProperties [document]{pdfstandard-X}{PDF/X-5g}
1700 \@@_xmp_add_pdfxid:
1701 },
1702 _pdfstandard / X-5N .code:n =
1703 {
1704 \prop_gset_eq:Nc \g__pdfmeta_standard_X_prop { g__pdfmeta_standard_pdf/X-5N_prop }
1705 \AddToDocumentProperties [document]{pdfstandard-X}{PDF/X-5n}
1706 \@@_xmp_add_pdfxid:
1707 },
1708 _pdfstandard / X-5PG .code:n =
1709 {
1710 \prop_gset_eq:Nc \g__pdfmeta_standard_X_prop { g__pdfmeta_standard_pdf/X-5PG_prop }
1711 \AddToDocumentProperties [document]{pdfstandard-X}{PDF/X-5pg}
1712 \@@_xmp_add_pdfxid:
1713 },
1714 _pdfstandard / X-6 .code:n =
1715 {
1716 \prop_gset_eq:Nc \g__pdfmeta_standard_X_prop { g__pdfmeta_standard_pdf/X-6_prop }
1717 \AddToDocumentProperties [document]{pdfstandard-X}{PDF/X-6}
1718 \@@_xmp_add_pdfxid:
1719 },
1720 _pdfstandard / X-6N .code:n =
1721 {
1722 \prop_gset_eq:Nc \g__pdfmeta_standard_X_prop { g__pdfmeta_standard_pdf/X-6N_prop }
1723 \AddToDocumentProperties [document]{pdfstandard-X}{PDF/X-6n}
1724 \@@_xmp_add_pdfxid:
1725 },
1726 _pdfstandard / X-6P .code:n =
1727 {
1728 \prop_gset_eq:Nc \g__pdfmeta_standard_X_prop { g__pdfmeta_standard_pdf/X-6P_prop }
1729 \AddToDocumentProperties [document]{pdfstandard-X}{PDF/X-6p}
1730 \@@_xmp_add_pdfxid:
1731 },
1732 _pdfstandard / UA-1 .code:n =
1733 {
1734 \prop_gset_eq:Nc \g__pdfmeta_standard_UA_prop { g__pdfmeta_standard_pdf/UA-1_prop }
1735 \pdfmeta_standard_family:nn{UA}{ \@@_force_standard_pdfversion: }
1736 \AddToDocumentProperties [document]{pdfstandard-UA}{{1}{}}
1737 \AddToHook{begindocument/before}
1738 {
1739 \prop_gput:Nnn \g__pdfmeta_standard_prop {omit_CID}{}
1740 }
1741 },
1742 % \end{macrocode}
1743 % currently it is not possible to merge requirements - these need some thoughts as
1744 % every standard has some common keys like the name or the yes.
1745 % We therefore add some requirements manually.
1746 %
1747 % \begin{macrocode}
1748 _pdfstandard / UA-2 .code:n =
1749 {
1750 \prop_gset_eq:Nc \g__pdfmeta_standard_UA_prop { g__pdfmeta_standard_pdf/UA-2_prop }
1751 \pdfmeta_standard_family:nn{UA}{\@@_force_standard_pdfversion:}
1752 \AddToDocumentProperties [document]{pdfstandard-UA}{{2}{2024}}
1753 % \end{macrocode}
1754 % 2025-06-11 \verb+Trailer_no_Info+ is only a should not a shall in UA-2 so we do not force it.
1755 % \begin{macrocode}
1756 %\AddToHook{begindocument/before}
1757 %{\prop_gput:Nnn \g__pdfmeta_standard_prop {Trailer_no_Info}{}}
1758 \AddToHook{begindocument/before}
1759 {
1760 \@@_xmp_wtpdf_accessibility_declaration:
1761 \@@_xmp_wtpdf_reuse_declaration:
1762 \cs_set_eq:NN\@@_xmp_wtpdf_accessibility_declaration:\prg_do_nothing:
1763 \cs_set_eq:NN\@@_xmp_wtpdf_reuse_declaration:\prg_do_nothing:
1764 }
1765 },
1766 xmp .choice:,
1767 xmp / true .code:n = { \bool_gset_true:N \g_@@_xmp_bool },
1768 xmp / false .code:n = { \bool_gset_false:N \g_@@_xmp_bool},
1769 xmp .default:n = true,
1770 % \end{macrocode}
1771 % These keys allow to disable or force the wtpdf declarations.
1772 % Currently the content can not be changed and once they have been disabled there
1773 % are gone. This will perhaps change.
1774 % \begin{macrocode}
1775 xmp / wtpdf .code:n =
1776 {
1777 \keys_set:nn {@@/xmp}{#1}
1778 },
1779 }
1780 \keys_define:nn {@@/xmp}
1781 {
1782 reuse .choice:,
1783 reuse / true .code:n = \@@_xmp_wtpdf_reuse_declaration:,
1784 reuse / false .code:n =
1785 {
1786 \cs_set_eq:NN \@@_xmp_wtpdf_reuse_declaration: \prg_do_nothing:
1787 },
1788 accessibility .choice:,
1789 accessibility / true .code:n = \@@_xmp_wtpdf_accessibility_declaration:,
1790 accessibility /false .code:n =
1791 {
1792 \cs_set_eq:NN \@@_xmp_wtpdf_accessibility_declaration: \prg_do_nothing:
1793 },
1794 }
1795 % \end{macrocode}
1796 % XMP debugging option
1797 % \begin{macrocode}
1798 \bool_new:N \g_@@_xmp_export_bool
1799 \str_new:N \g_@@_xmp_export_str
1800
1801 \keys_define:nn { document / metadata }
1802 {
1803 ,debug .code:n =
1804 {
1805 \keys_set:nn { document / metadata / debug } {#1}
1806 }
1807 ,debug / xmp-export .choice:
1808 ,debug / xmp-export / true .code:n=
1809 {
1810 \bool_gset_true:N \g_@@_xmp_export_bool
1811 \str_gset_eq:NN \g_@@_xmp_export_str \c_sys_jobname_str
1812 }
1813 ,debug / xmp-export / false .code:n =
1814 {
1815 \bool_gset_false:N \g_@@_xmp_export_bool
1816 }
1817 ,debug / xmp-export /unknown .code:n =
1818 {
1819 \bool_gset_true:N \g_@@_xmp_export_bool
1820 \str_gset:Nn \g_@@_xmp_export_str { #1 }
1821 }
1822 ,debug / xmp-export .default:n = true
1823 }
1824 % \end{macrocode}
1825 % \subsection{Messages}
1826 % \begin{macrocode}
1827 \msg_new:nnn{pdfmeta}{xmp-defined}{The~XMP~#1~`#2`~is~already~declared}
1828 \msg_new:nnn{pdfmeta}{xmp-undefined}{The~XMP~#1~`#2`~is~undefined}
1829 \msg_new:nnn{pdfmeta}{colorprofile-undefined}{The~colorprofile~`#1`~is~unknown}
1830 % \end{macrocode}
1831 % \subsection{Some helper commands}
1832 % \subsubsection{Generate a BOM}
1833 % \begin{macro}{\@@_xmp_generate_bom:}
1834 % \begin{macrocode}
1835 \bool_lazy_or:nnTF
1836 { \sys_if_engine_luatex_p: }
1837 { \sys_if_engine_xetex_p: }
1838 {
1839 \cs_new:Npn \@@_xmp_generate_bom:
1840 { \char_generate:nn {"FEFF}{12} }
1841 }
1842 {
1843 \cs_new:Npn \@@_xmp_generate_bom:
1844 {
1845 \char_generate:nn {"EF}{12}
1846 \char_generate:nn {"BB}{12}
1847 \char_generate:nn {"BF}{12}
1848 }
1849 }
1850 % \end{macrocode}
1851 % \end{macro}
1852 %
1853 % \subsubsection{Indentation}
1854 % We provide a command which indents the xml based
1855 % on a counter, and one which accepts a fix number.
1856 % The counter can be increased and decreased.
1857 %
1858 % \begin{variable}{\l_@@_xmp_indent_int}
1859 % \begin{macrocode}
1860 \int_new:N \l_@@_xmp_indent_int
1861 % \end{macrocode}
1862 % \end{variable}
1863 % \begin{macro}{\@@_xmp_indent:,
1864 % \@@_xmp_indent:n,
1865 % \@@_xmp_incr_indent:,
1866 % \@@_xmp_decr_indent:}
1867 % \begin{macrocode}
1868 \cs_new:Npn \@@_xmp_indent:
1869 {
1870 \iow_newline:
1871 \prg_replicate:nn {\l_@@_xmp_indent_int}{\c_space_tl}
1872 }
1873
1874 \cs_new:Npn \@@_xmp_indent:n #1
1875 {
1876 \iow_newline:
1877 \prg_replicate:nn {#1}{\c_space_tl}
1878 }
1879
1880 \cs_new_protected:Npn \@@_xmp_incr_indent:
1881 {
1882 \int_incr:N \l_@@_xmp_indent_int
1883 }
1884
1885 \cs_new_protected:Npn \@@_xmp_decr_indent:
1886 {
1887 \int_decr:N \l_@@_xmp_indent_int
1888 }
1889 % \end{macrocode}
1890 % \end{macro}
1891 %
1892 % \subsubsection{Date and time handling}
1893 % If the date is given in PDF format we have to split it to create
1894 % the XMP format. We use a precompiled regex for this.
1895 % To some extend the regex can also handle incomplete dates.
1896 %
1897 % \begin{variable}{\l_@@_xmp_date_regex}
1898 % \begin{macrocode}
1899 \regex_new:N \l_@@_xmp_date_regex
1900 \regex_set:Nn \l_@@_xmp_date_regex
1901 {D:(\d{4})(\d{2})(\d{2})(\d{2})?(\d{2})?(\d{2})?([Z\+\-])?(?:(\d{2})\')?(?:(\d{2})\')?}
1902 % \end{macrocode}
1903 % \end{variable}
1904 %
1905 % \begin{macro}{\@@_xmp_date_split:nN}
1906 % This command takes a date in PDF format, splits it with the regex and
1907 % stores the captures in a sequence.
1908 % \begin{macrocode}
1909 \cs_new_protected:Npn \@@_xmp_date_split:nN #1 #2 %#1 date, #2 seq
1910 {
1911 \regex_split:NnN \l_@@_xmp_date_regex {#1} #2
1912 }
1913 \cs_generate_variant:Nn \@@_xmp_date_split:nN {VN,eN}
1914 % \end{macrocode}
1915 % \end{macro}
1916
1917 % \begin{macro}[EXP]{\@@_xmp_print_date:N}
1918 % This prints the date stored in a sequence as created
1919 % by the previous command.
1920 %
1921 % \begin{macrocode}
1922 \cs_new:Npn\@@_xmp_print_date:N #1 % seq
1923 {
1924 \tl_if_blank:eTF { \seq_item:Nn #1 {1} }
1925 {
1926 \seq_item:Nn #1 {2} %year
1927 -
1928 \seq_item:Nn #1 {3} %month
1929 -
1930 \seq_item:Nn #1 {4} % day
1931 \tl_if_blank:eF
1932 { \seq_item:Nn #1 {5} }
1933 { T \seq_item:Nn #1 {5} } %hour
1934 \tl_if_blank:eF
1935 { \seq_item:Nn #1 {6} }
1936 { : \seq_item:Nn #1 {6} } %minutes
1937 \tl_if_blank:eF
1938 { \seq_item:Nn #1 {7} }
1939 { : \seq_item:Nn #1 {7} } %seconds
1940 \seq_item:Nn #1 {8} %Z,+,-
1941 \seq_item:Nn #1 {9}
1942 \tl_if_blank:eF
1943 { \seq_item:Nn #1 {10} }
1944 { : \seq_item:Nn #1 {10} }
1945 }
1946 {
1947 \seq_item:Nn #1 {1}
1948 }
1949 }
1950 % \end{macrocode}
1951 % \end{macro}
1952 %
1953 % \begin{variable}{\l_@@_xmp_currentdate_tl,\l_@@_xmp_currentdate_seq}
1954 % The tl var contains the date of the log-file in PDF format,
1955 % the seq the result split with the regex.
1956 % \begin{macrocode}
1957 \tl_new:N \l_@@_xmp_currentdate_tl
1958 \seq_new:N \l_@@_xmp_currentdate_seq
1959 % \end{macrocode}
1960 % \end{variable}
1961 %
1962 % \begin{macro}{\@@_xmp_date_get:nNN}
1963 % This checks a document property and if empty uses the current date.
1964 % \begin{macrocode}
1965 \cs_new_protected:Npn \@@_xmp_date_get:nNN #1 #2 #3
1966 %#1 property, #2 tl var with PDF date, #3 seq for split date
1967 {
1968 \tl_set:Ne #2 { \pdfmanagement_get_documentproperty:n{#1} }
1969 \tl_if_blank:VTF #2
1970 {
1971 \seq_set_eq:NN #3 \l_@@_xmp_currentdate_seq
1972 \tl_set_eq:NN #2 \l_@@_xmp_currentdate_tl
1973 }
1974 {
1975 \@@_xmp_date_split:VN #2 #3
1976 }
1977 }
1978 % \end{macrocode}
1979 % \end{macro}
1980 % \subsubsection{UUID}
1981 % We need a command to generate an uuid
1982 % \begin{macro}{\@@_xmp_create_uuid:nN}
1983 % \begin{macrocode}
1984 \cs_new_protected:Npn \@@_xmp_create_uuid:nN #1 #2
1985 {
1986 \str_set:Ne#2 {\str_lowercase:f{\tex_mdfivesum:D{#1}}}
1987 \str_set:Ne#2
1988 { uuid:
1989 \str_range:Nnn #2{1}{8}
1990 -\str_range:Nnn#2{9}{12}
1991 -4\str_range:Nnn#2{13}{15}
1992 -8\str_range:Nnn#2{16}{18}
1993 -\str_range:Nnn#2{19}{30}
1994 }
1995 }
1996 % \end{macrocode}
1997 % \end{macro}
1998 %
1999 % \subsubsection{Purifying and escaping of strings}
2000 %
2001 % \begin{macro}{\@@_xmp_sanitize:nN}
2002 % We have to sanitize the user input. For this we pass
2003 % it through |\text_purify| and then replace a few special chars.
2004 % \begin{macrocode}
2005 \cs_new_protected:Npn \@@_xmp_sanitize:nN #1 #2
2006 %#1 input string, #2 str with the output
2007 {
2008 \group_begin:
2009 \text_declare_purify_equivalent:Nn \& {\tl_to_str:N & }
2010 \text_declare_purify_equivalent:Nn \texttilde {\c_tilde_str}
2011 \tl_set:Ne \l_@@_tmpa_tl { \text_purify:n {#1} }
2012 \str_gset:Ne \g_@@_tmpa_str { \tl_to_str:N \l_@@_tmpa_tl }
2013 \str_greplace_all:Nnn\g_@@_tmpa_str {&}{&amp;}
2014 \str_greplace_all:Nnn\g_@@_tmpa_str {<}{&lt;}
2015 \str_greplace_all:Nnn\g_@@_tmpa_str {>}{&gt;}
2016 \str_greplace_all:Nnn\g_@@_tmpa_str {"}{&quot;}
2017 \group_end:
2018 \str_set_eq:NN #2 \g_@@_tmpa_str
2019 }
2020
2021 \cs_generate_variant:Nn\@@_xmp_sanitize:nN {VN}
2022 % \end{macrocode}
2023 % \end{macro}
2024 %
2025 % \subsection{Language handling}
2026 % The language of the metadata is used in various attributes, so we store it in
2027 % command.
2028 % \begin{variable}{\l_@@_xmp_doclang_tl,\l_@@_xmp_metalang_tl}
2029 % \begin{macrocode}
2030 \tl_new:N \l_@@_xmp_doclang_tl
2031 \tl_new:N \l_@@_xmp_metalang_tl
2032 % \end{macrocode}
2033 % \end{variable}
2034 %
2035 % The language is retrieved at the start of the packet. We assume that
2036 % |lang| is always set and so don't use the |x-default| value of \pkg{hyperxmp}.
2037 %
2038 % \begin{variable}{\l_@@_xmp_lang_regex}
2039 % \begin{macrocode}
2040 \regex_new:N\l_@@_xmp_lang_regex
2041 \regex_set:Nn\l_@@_xmp_lang_regex {\A\[([A-Za-z\-]+)\](.*)}
2042 % \end{macrocode}
2043 % \end{variable}
2044 %
2045 % \begin{macrocode}
2046 \cs_new_protected:Npn \@@_xmp_lang_get:nNN #1 #2 #3
2047 % #1 text, #2 tl var for lang match (or default), #3 tl var for text
2048 {
2049 \regex_extract_once:NnN \l_@@_xmp_lang_regex {#1}\l_@@_tmpa_seq
2050 \seq_if_empty:NTF \l_@@_tmpa_seq
2051 {
2052 \tl_set:Nn #2 \l_@@_xmp_metalang_tl
2053 \tl_set:Nn #3 {#1}
2054 }
2055 {
2056 \tl_set:Ne #2 {\seq_item:Nn\l_@@_tmpa_seq{2}}
2057 \tl_set:Ne #3 {\seq_item:Nn\l_@@_tmpa_seq{3}}
2058 }
2059 }
2060 \cs_generate_variant:Nn \@@_xmp_lang_get:nNN {eNN,VNN}
2061 % \end{macrocode}
2062 %
2063
2064
2065 % \subsection{Filling the packet}
2066 % This tl var that holds the whole packet
2067 % \begin{variable}{\g_@@_xmp_packet_tl}
2068 % \begin{macrocode}
2069 \tl_new:N \g_@@_xmp_packet_tl
2070 % \end{macrocode}
2071 % \end{variable}
2072 %
2073 % \subsubsection{Helper commands to add lines and lists}
2074 %
2075 % \begin{macro}{\@@_xmp_add_packet_chunk:n}
2076 % This is the most basic command.
2077 % It is meant to produce a line and will use the current indent.
2078 % \begin{macrocode}
2079 \cs_new_protected:Npn \@@_xmp_add_packet_chunk:n #1
2080 {
2081 \tl_gput_right:Ne\g_@@_xmp_packet_tl
2082 {
2083 \@@_xmp_indent: \exp_not:n{#1}
2084 }
2085 }
2086 \cs_generate_variant:Nn \@@_xmp_add_packet_chunk:n {e}
2087 % \end{macrocode}
2088 % \end{macro}
2089
2090 % \begin{macro}{\@@_xmp_add_packet_chunk:nN}
2091 % This is the most basic command.
2092 % It is meant to produce a line and will use the current indent.
2093 % \begin{macrocode}
2094 \cs_new_protected:Npn \@@_xmp_add_packet_chunk:nN #1 #2
2095 {
2096 \tl_put_right:Ne#2
2097 {
2098 \@@_xmp_indent: \exp_not:n{#1}
2099 }
2100 }
2101 \cs_generate_variant:Nn \@@_xmp_add_packet_chunk:nN {eN}
2102 % \end{macrocode}
2103 % \end{macro}
2104
2105 % \begin{macro}{\@@_xmp_add_packet_open:nn}
2106 % This commands opens a xml structure and increases the indent.
2107 % \begin{macrocode}
2108 \cs_new_protected:Npn \@@_xmp_add_packet_open:nn #1 #2 %#1 prefix #2 name
2109 {
2110 \@@_xmp_add_packet_chunk:n {<#1:#2>}
2111 \@@_xmp_incr_indent:
2112 }
2113 \cs_generate_variant:Nn \@@_xmp_add_packet_open:nn {ne}
2114 % \end{macrocode}
2115 % \end{macro}
2116
2117 % \begin{macro}{\@@_xmp_add_packet_open_attr:nnn}
2118 % This commands opens a xml structure too but allows also to give an
2119 % attribute.
2120 % \begin{macrocode}
2121 \cs_new_protected:Npn \@@_xmp_add_packet_open_attr:nnn #1 #2 #3
2122 %#1 prefix #2 name #3 attr
2123 {
2124 \@@_xmp_add_packet_chunk:n {<#1:#2~#3>}
2125 \@@_xmp_incr_indent:
2126 }
2127 \cs_generate_variant:Nn \@@_xmp_add_packet_open_attr:nnn {nne}
2128 % \end{macrocode}
2129 % \end{macro}
2130
2131 % \begin{macro}{\@@_xmp_add_packet_close:nn}
2132 % This closes a structure and decreases the indent.
2133 % \begin{macrocode}
2134 \cs_new_protected:Npn \@@_xmp_add_packet_close:nn #1 #2 %#1 prefix #2:name
2135 {
2136 \@@_xmp_decr_indent:
2137 \@@_xmp_add_packet_chunk:n {</#1:#2>}
2138 }
2139 % \end{macrocode}
2140 % \end{macro}
2141 % \begin{macro}{\@@_xmp_add_packet_line:nnn}
2142 % This will produce a full line with open and closing xml.
2143 % The content is sanitized. We test if there is content to be
2144 % able to suppress data which has not be set.
2145 % \begin{macrocode}
2146 \cs_new_protected:Npn \@@_xmp_add_packet_line:nnn #1 #2 #3
2147 %#1 prefix #2 name #3 content
2148 {
2149 \tl_if_blank:nF {#3}
2150 {
2151 \@@_xmp_sanitize:nN {#3}\l_@@_tmpa_str
2152 \@@_xmp_add_packet_chunk:e {<#1:#2>\l_@@_tmpa_str</#1:#2>}
2153 }
2154 }
2155 \cs_generate_variant:Nn \@@_xmp_add_packet_line:nnn {nne,nnV,nee}
2156 % \end{macrocode}
2157 % \end{macro}
2158 % \begin{macro}{\@@_xmp_add_packet_line:nnnN}
2159 % This will produce a full line with open and closing xml and store it in
2160 % the given tl-var. This allows to prebuild blocks and then to test if there are empty.
2161 % The content is sanitized. We test if there is content to be
2162 % able to suppress data which has not be set.
2163 % \begin{macrocode}
2164 \cs_new_protected:Npn \@@_xmp_add_packet_line:nnnN #1 #2 #3 #4
2165 %#1 prefix #2 name #3 content #4 tl_var to prebuilt.
2166 {
2167 \tl_if_blank:nF {#3}
2168 {
2169 \@@_xmp_sanitize:nN {#3}\l_@@_tmpa_str
2170 \@@_xmp_add_packet_chunk:eN {<#1:#2>\l_@@_tmpa_str</#1:#2>} #4
2171 }
2172 }
2173 \cs_generate_variant:Nn \@@_xmp_add_packet_line:nnnN {nneN}
2174 % \end{macrocode}
2175 % \end{macro}
2176 % \begin{macro}{\@@_xmp_add_packet_line_attr:nnnn}
2177 % A similar command with attribute
2178 % \begin{macrocode}
2179 \cs_new_protected:Npn \@@_xmp_add_packet_line_attr:nnnn #1 #2 #3 #4
2180 %#1 prefix #2 name #3 attribute #4 content
2181 {
2182 \tl_if_blank:nF {#4}
2183 {
2184 \@@_xmp_sanitize:nN {#4}\l_@@_tmpa_str
2185 \@@_xmp_add_packet_chunk:e {<#1:#2~#3>\l_@@_tmpa_str</#1:#2>}
2186 }
2187 }
2188 \cs_generate_variant:Nn \@@_xmp_add_packet_line_attr:nnnn {nnee,nneV}
2189 % \end{macrocode}
2190 % \end{macro}
2191 %
2192 % \begin{macro}{\@@_xmp_add_packet_line_default:nnnn}
2193 % \begin{macrocode}
2194 \cs_new_protected:Npn \@@_xmp_add_packet_line_default:nnnn #1 #2 #3 #4
2195 % #1 prefix #2 name #3 default #4 content
2196 {
2197 \tl_if_blank:nTF { #4 }
2198 {
2199 \tl_set:Nn \l_@@_tmpa_tl {#3}
2200 }
2201 {
2202 \tl_set:Nn \l_@@_tmpa_tl {#4}
2203 }
2204 \@@_xmp_add_packet_line:nnV {#1}{#2}\l_@@_tmpa_tl
2205 }
2206 \cs_generate_variant:Nn \@@_xmp_add_packet_line_default:nnnn {nnee}
2207 % \end{macrocode}
2208 % \end{macro}
2209 % Some data are stored as unordered (Bag) or ordered lists (Seq) or (Alt).
2210 % The first variant are for simple text without language support:
2211 % \begin{macrocode}
2212 \cs_new_protected:Npn \@@_xmp_add_packet_list_simple:nnnn #1 #2 #3 #4
2213 %#1 prefix, #2 name, #3 type (Seq/Bag/Alt) #4 a clist
2214 {
2215 \clist_if_empty:nF { #4 }
2216 {
2217 \@@_xmp_add_packet_open:nn {#1}{#2}
2218 \@@_xmp_add_packet_open:nn {rdf}{#3}
2219 \clist_map_inline:nn {#4}
2220 {
2221 \@@_xmp_add_packet_line:nnn
2222 {rdf}{li}{##1}
2223 }
2224 \@@_xmp_add_packet_close:nn{rdf}{#3}
2225 \@@_xmp_add_packet_close:nn {#1}{#2}
2226 }
2227 }
2228 \cs_generate_variant:Nn \@@_xmp_add_packet_list_simple:nnnn {nnnV,nnne}
2229 % \end{macrocode}
2230 % Here we check also for the language.
2231 % \begin{macrocode}
2232 \cs_new_protected:Npn \@@_xmp_add_packet_list:nnnn #1 #2 #3 #4
2233 %#1 prefix, #2 name, #3 type (Seq/Bag/Alt) #4 a clist
2234 {
2235 \clist_if_empty:nF { #4 }
2236 {
2237 \@@_xmp_add_packet_open:nn {#1}{#2}
2238 \@@_xmp_add_packet_open:nn {rdf}{#3}
2239 \clist_map_inline:nn {#4}
2240 {
2241 \@@_xmp_lang_get:nNN {##1}\l_@@_tmpa_tl\l_@@_tmpb_tl
2242 % \end{macrocode}
2243 % change 2024-02-22. There should be if possible a x-default
2244 % entry as some viewers need that. So if the language is equal to the
2245 % main language we use that. This assumes that the user hasn't marked
2246 % every entry as some other language!
2247 % x-default has to be the first entry, see issue \#92,
2248 % so we have to go through the list twice.
2249 % \begin{macrocode}
2250 \tl_if_eq:eeT{\l_@@_tmpa_tl}{\l_@@_xmp_metalang_tl}
2251 {
2252 \@@_xmp_add_packet_line_attr:nneV
2253 {rdf}{li}{xml:lang="x-default" }\l_@@_tmpb_tl
2254 \@@_xmp_add_packet_line_attr:nneV
2255 {rdf}{li}{xml:lang="\l_@@_tmpa_tl" }\l_@@_tmpb_tl
2256 }
2257 }
2258 \clist_map_inline:nn {#4}
2259 {
2260 \@@_xmp_lang_get:nNN {##1}\l_@@_tmpa_tl\l_@@_tmpb_tl
2261 \tl_if_eq:eeF{\l_@@_tmpa_tl}{\l_@@_xmp_metalang_tl}
2262 {
2263 \@@_xmp_add_packet_line_attr:nneV
2264 {rdf}{li}{xml:lang="\l_@@_tmpa_tl" }\l_@@_tmpb_tl
2265 }
2266 }
2267 \@@_xmp_add_packet_close:nn{rdf}{#3}
2268 \@@_xmp_add_packet_close:nn {#1}{#2}
2269 }
2270 }
2271 \cs_generate_variant:Nn \@@_xmp_add_packet_list:nnnn {nnne}
2272 % \end{macrocode}
2273 %
2274 % \subsubsection{Building the main packet}
2275 %
2276 % \begin{macro}{\@@_xmp_build_packet:}
2277 % This is the main command to build the packet.
2278 % As data has to be set and collected first, it will be expanded
2279 % rather late in the document.
2280 %
2281 % \begin{macrocode}
2282 \cs_new_protected:Npn \@@_xmp_build_packet:
2283 {
2284 % \end{macrocode}
2285 % Get the main languages
2286 % \begin{NOTE}{UF}
2287 % think if an error is needed for empty lang.
2288 % \end{NOTE}
2289 % \begin{macrocode}
2290 \tl_set:Ne \l_@@_xmp_doclang_tl {\pdfmanagement_get_documentproperty:n{document/lang}}
2291 \tl_set:Ne \l_@@_xmp_metalang_tl {\pdfmanagement_get_documentproperty:n{hyperref/pdfmetalang}}
2292 \tl_if_blank:VT \l_@@_xmp_metalang_tl
2293 { \cs_set_eq:NN \l_@@_xmp_metalang_tl\l_@@_xmp_doclang_tl}
2294 % \end{macrocode}
2295 % we preprocess a number of data to be able to suppress them and their schema
2296 % if there are unused. Currently only done for iptc
2297 % \begin{macrocode}
2298 \@@_xmp_build_iptc_data:N \l_@@_xmp_iptc_data_tl
2299 \tl_if_empty:NT \l_@@_xmp_iptc_data_tl
2300 {
2301 \seq_remove_all:Nn \l_@@_xmp_schema_seq { Iptc4xmpCore }
2302 }
2303 % \end{macrocode}
2304 % The start of the package.
2305 % No need to try to juggle with catcode, this is fix text
2306 % \begin{macrocode}
2307 \@@_xmp_add_packet_chunk:e
2308 {<?xpacket~begin="\@@_xmp_generate_bom:"~id="W5M0MpCehiHzreSzNTczkc9d"?>}
2309 \@@_xmp_add_packet_open:nn{x}{xmpmeta~xmlns:x="adobe:ns:meta/"}
2310 \@@_xmp_add_packet_open:ne{rdf}
2311 {RDF~xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns\c_hash_str"}
2312 % \end{macrocode}
2313 % The rdf namespaces
2314 % \begin{macrocode}
2315 \@@_xmp_add_packet_open_attr:nne
2316 {rdf}{Description}{rdf:about="" \g_@@_xmp_xmlns_tl}
2317 % \end{macrocode}
2318 % The extensions
2319 % \begin{macrocode}
2320 \@@_xmp_add_packet_open:nn{pdfaExtension}{schemas}
2321 \@@_xmp_add_packet_open:nn {rdf}{Bag}
2322 \seq_map_inline:Nn \l_@@_xmp_schema_seq
2323 {
2324 \tl_use:c { g_@@_xmp_schema_##1_tl }
2325 }
2326 \@@_xmp_add_packet_close:nn {rdf}{Bag}
2327 \@@_xmp_add_packet_close:nn {pdfaExtension}{schemas}
2328 % \end{macrocode}
2329 % Now starts the part with the data.
2330 % \begin{macrocode}
2331 % data
2332 \@@_xmp_build_pdf:
2333 \@@_xmp_build_xmpRights:
2334 \@@_xmp_build_standards: %pdfaid,pdfxid,pdfuaid
2335 \@@_xmp_build_pdfd:
2336 \@@_xmp_build_dc:
2337 \@@_xmp_build_photoshop:
2338 \@@_xmp_build_xmp:
2339 \@@_xmp_build_xmpMM:
2340 \@@_xmp_build_prism:
2341 \@@_xmp_build_iptc:
2342 \@@_xmp_build_tdm:
2343 \@@_xmp_build_user: %user additions
2344 % end
2345 \@@_xmp_add_packet_close:nn {rdf}{Description}
2346 \@@_xmp_add_packet_close:nn {rdf}{RDF}
2347 \@@_xmp_add_packet_close:nn {x}{xmpmeta}
2348 \int_set:Nn \l_@@_xmp_indent_int{20}
2349 \prg_replicate:nn{10}{\@@_xmp_add_packet_chunk:n {}}
2350 \int_zero:N \l_@@_xmp_indent_int
2351 \@@_xmp_add_packet_chunk:n {<?xpacket~end="w"?>}
2352 }
2353 % \end{macrocode}
2354 % \end{macro}
2355
2356 % \subsection{Building the chunks: rdf namespaces}
2357 % This is the list of external names spaces.
2358 % They are rather simple, and we store them directly
2359 % into a string. Special chars should be escaped properly,
2360 % see e.g. |\c_hash_str| for the hash.
2361
2362 % \begin{variable}{\g_@@_xmp_xmlns_tl,\g_@@_xmp_xmlns_prop}
2363 % The string will hold the prepared chunk, the prop stores the name spaces
2364 % so that one can check on the user level for duplicates.
2365 % \begin{macrocode}
2366 \str_new:N \g_@@_xmp_xmlns_tl
2367 \prop_new:N \g_@@_xmp_xmlns_prop
2368 % \end{macrocode}
2369 % \end{variable}
2370 % \begin{macro}{\@@_xmp_xmlns_new:nn}
2371 % \begin{macrocode}
2372 \cs_new_protected:Npn \@@_xmp_xmlns_new:nn #1 #2
2373 {
2374 \prop_gput:Nnn \g_@@_xmp_xmlns_prop {#1}{#2}
2375 \tl_gput_right:Ne \g_@@_xmp_xmlns_tl
2376 {
2377 \@@_xmp_indent:n{4} xmlns:\exp_not:n{#1="#2"}
2378 }
2379 }
2380 % \end{macrocode}
2381 % \end{macro}
2382 % Now we fill the data. The list is more or less the same as in hyperxmp
2383 % The pdfxid entry is only added if an X standard is used, see issue \#50
2384 % and the schema below.
2385 % \begin{macrocode}
2386 \@@_xmp_xmlns_new:nn {pdf} {http://ns.adobe.com/pdf/1.3/}
2387 \@@_xmp_xmlns_new:nn {xmpRights}{http://ns.adobe.com/xap/1.0/rights/}
2388 \@@_xmp_xmlns_new:nn {dc} {http://purl.org/dc/elements/1.1/}
2389 \@@_xmp_xmlns_new:nn {photoshop}{http://ns.adobe.com/photoshop/1.0/}
2390 \@@_xmp_xmlns_new:nn {xmp} {http://ns.adobe.com/xap/1.0/}
2391 \@@_xmp_xmlns_new:nn {xmpMM} {http://ns.adobe.com/xap/1.0/mm/}
2392 \@@_xmp_xmlns_new:nn {stEvt}
2393 {http://ns.adobe.com/xap/1.0/sType/ResourceEvent\c_hash_str}
2394 \@@_xmp_xmlns_new:nn {pdfaid} {http://www.aiim.org/pdfa/ns/id/}
2395 \@@_xmp_xmlns_new:nn {pdfuaid} {http://www.aiim.org/pdfua/ns/id/}
2396 \@@_xmp_xmlns_new:nn {pdfx} {http://ns.adobe.com/pdfx/1.3/}
2397 %\@@_xmp_xmlns_new:nn {pdfxid} {http://www.npes.org/pdfx/ns/id/}
2398 \@@_xmp_xmlns_new:nn {prism} {http://prismstandard.org/namespaces/basic/3.0/}
2399 %\@@_xmp_xmlns_new:nn {jav} {http://www.niso.org/schemas/jav/1.0/}
2400 %\@@_xmp_xmlns_new:nn {xmpTPg} {http://ns.adobe.com/xap/1.0/t/pg/}
2401 \@@_xmp_xmlns_new:nn {stFnt} {http://ns.adobe.com/xap/1.0/sType/Font\c_hash_str}
2402 \@@_xmp_xmlns_new:nn {Iptc4xmpCore}{http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/}
2403 \@@_xmp_xmlns_new:nn {pdfaExtension}{http://www.aiim.org/pdfa/ns/extension/}
2404 \@@_xmp_xmlns_new:nn {pdfaSchema}{http://www.aiim.org/pdfa/ns/schema\c_hash_str}
2405 \@@_xmp_xmlns_new:nn {pdfaProperty}{http://www.aiim.org/pdfa/ns/property\c_hash_str}
2406 \@@_xmp_xmlns_new:nn {pdfaType} {http://www.aiim.org/pdfa/ns/type\c_hash_str}
2407 \@@_xmp_xmlns_new:nn {pdfaField}{http://www.aiim.org/pdfa/ns/field\c_hash_str}
2408 \@@_xmp_xmlns_new:nn {tdm}{http://www.w3.org/ns/tdmrep/}
2409 % \end{macrocode}
2410
2411 % \subsection{Building the chunks: Extensions}
2412 % In this part local name spaces or additional names in a name space can be declared.
2413 % A \enquote{schema} declaration consist of the declaration of the name, uri and prefix
2414 % which then surrounds a bunch of property declarations.
2415 % The current code doesn't support all syntax options but sticks to
2416 % what is used in \pkg{hyperxmp} and \pkg{pdfx}.
2417 % If needed it can be extended later.
2418 %
2419 % \begin{variable}{\l_@@_xmp_schema_seq}
2420 % This variable will hold the list of prefix so that we can loop
2421 % to produce the final XML
2422 % \begin{macrocode}
2423 \seq_new:N \l_@@_xmp_schema_seq
2424 % \end{macrocode}
2425 % \end{variable}
2426 %
2427 % \begin{macro}{\@@_xmp_schema_new:nnn}
2428 % With this command a new schema can be declared. The main tl contains the
2429 % XML wrapper code, it then includes the list of properties which are
2430 % created with the next command.
2431 % \begin{macrocode}
2432 \cs_new_protected:Npn \@@_xmp_schema_new:nnn #1 #2 #3
2433 %#1 name #2 prefix, #3 text
2434 {
2435 \tl_if_exist:cTF { g_@@_xmp_schema_#2_tl }
2436 {
2437 \msg_warning:nnnn{pdfmeta}{xmp-defined}{schema}{#2}
2438 }
2439 {
2440 \seq_put_right:Nn \l_@@_xmp_schema_seq { #2 }
2441 \tl_new:c { g_@@_xmp_schema_#2_tl }
2442 \tl_new:c { g_@@_xmp_schema_#2_properties_tl }
2443 \tl_gput_right:cn { g_@@_xmp_schema_#2_tl }
2444 {
2445 \@@_xmp_add_packet_open_attr:nnn{rdf}{li}{rdf:parseType="Resource"}
2446 \@@_xmp_add_packet_line:nnn {pdfaSchema}{schema}{#1}
2447 \@@_xmp_add_packet_line:nnn {pdfaSchema}{prefix}{#2}
2448 \@@_xmp_add_packet_line:nnn {pdfaSchema}{namespaceURI}{#3}
2449 \@@_xmp_add_packet_open:nn {pdfaSchema}{property}
2450 \@@_xmp_add_packet_open:nn{rdf}{Seq}
2451 \tl_use:c { g_@@_xmp_schema_#2_properties_tl }
2452 \@@_xmp_add_packet_close:nn{rdf}{Seq}
2453 \@@_xmp_add_packet_close:nn {pdfaSchema}{property}
2454 \cs_if_exist_use:c {@@_xmp_schema_#2_additions:}
2455 \@@_xmp_add_packet_close:nn{rdf}{li}
2456 }
2457 }
2458 }
2459 % \end{macrocode}
2460 % \end{macro}
2461 %
2462 %
2463 %
2464 % \begin{macro}{\@@_xmp_property_new:nnnnn}
2465 % This adds a property to a schema.
2466 % \begin{macrocode}
2467 \prop_new:N\g_@@_xmp_schema_property_prop
2468 \cs_new_protected:Npn \@@_xmp_property_new:nnnnn #1 #2 #3 #4 #5 %
2469 %#1 schema #2 name, #3 type, #4 category #5 description
2470 {
2471 \tl_if_exist:cTF { g_@@_xmp_schema_#1_properties_tl }
2472 {
2473 \prop_get:NeNF \g_@@_xmp_schema_property_prop {#1:#2}\l_@@_tmpa_tl
2474 {
2475 \prop_gput:Nee \g_@@_xmp_schema_property_prop {#1:#2}{#3}
2476 \tl_gput_right:cn { g_@@_xmp_schema_#1_properties_tl }
2477 {
2478 \@@_xmp_add_packet_open:nn {rdf}{li~rdf:parseType="Resource"}
2479 \@@_xmp_add_packet_line:nnn {pdfaProperty}{name}{#2}
2480 \@@_xmp_add_packet_line:nnn {pdfaProperty}{valueType}{#3}
2481 \@@_xmp_add_packet_line:nnn {pdfaProperty}{category}{#4}
2482 \@@_xmp_add_packet_line:nnn {pdfaProperty}{description}{#5}
2483 \@@_xmp_add_packet_close:nn{rdf}{li}
2484 }
2485 }
2486 }
2487 {
2488 \msg_warning:nnnn{pdfmeta}{xmp-undefined}{schema}{#1}
2489 }
2490 }
2491 % \end{macrocode}
2492 % \end{macro}
2493
2494 % \begin{macro}{\@@_xmp_add_packet_field:nnn}
2495 % This adds a field to a schema.
2496 % \begin{macrocode}
2497 \cs_new_protected:Npn \@@_xmp_add_packet_field:nnn #1 #2 #3 %
2498 %#1 name #2 valuetype #3 description
2499 {
2500 \@@_xmp_add_packet_open_attr:nnn {rdf}{li}{rdf:parseType="Resource"}
2501 \@@_xmp_add_packet_line:nnn {pdfaField}{name}{#1}
2502 \@@_xmp_add_packet_line:nnn {pdfaField}{valueType}{#2}
2503 \@@_xmp_add_packet_line:nnn {pdfaField}{description}{#3}
2504 \@@_xmp_add_packet_close:nn{rdf}{li}
2505 }
2506 % \end{macrocode}
2507 % \end{macro}
2508 %
2509 % \subsubsection{The extension data}
2510 %
2511 % The list of extension has been reviewed and compared with
2512 % the list of namespaces which can be used in pdf/A-1\footnote{While
2513 % A-1 builds on PDF 1.4 and so it probably no longer relevant, it is
2514 % not quite clear if one can remove this for A-2 and newer, so we stay on the
2515 % safe side.}
2516 %
2517 %
2518 % [1]~\url{https://www.pdfa.org/wp-content/uploads/2011/08/tn0008_predefined_xmp_properties_in_pdfa-1_2008-03-20.pdf}
2519 % and the content of the namespaces as listed here
2520 % [2]~\url{https://developer.adobe.com/xmp/docs/XMPNamespaces/pdf/}
2521 %
2522 %
2523 % \begin{description}
2524 % \item[pdf] property: Trapped.
2525 % We ignore it, it seems to validate without it.
2526 % \item[xmpMM] properties DocumentID, InstanceID, VersionID,
2527 % Renditionclass declared by hyperxmp.
2528 % Properties InstanceID and OriginalDocumentID declared by pdfx (pdfx.xmp)
2529 % With the exception of OriginalDocumentID all are already allowed and
2530 % predefined.
2531 % \begin{macrocode}
2532 \@@_xmp_schema_new:nnn
2533 {XMP~Media~Management~Schema}
2534 {xmpMM}
2535 {http://ns.adobe.com/xap/1.0/mm/}
2536 \@@_xmp_property_new:nnnnn
2537 {xmpMM}
2538 {OriginalDocumentID}
2539 {URI}
2540 {internal}
2541 {The~common~identifier~for~all~versions~and~renditions~of~a~document.}
2542 % \end{macrocode}
2543 % \item[pdfaid] properties part and conformance are declared by hyperxmp, but
2544 % no here as already in http://www.aiim.org/pdfa/ns/id/. But we declare
2545 % year so that it can be used also with older A-standards.
2546 % \begin{macro}[no-user-doc]{pdfaid~(schema)}
2547 % \begin{macrocode}
2548 \@@_xmp_schema_new:nnn
2549 {PDF/A~Identification~Schema}
2550 {pdfaid}
2551 {http://www.aiim.org/pdfa/ns/id/}
2552 \@@_xmp_property_new:nnnnn
2553 {pdfaid}
2554 {year}
2555 {Integer}
2556 {internal}
2557 {Year~of~standard}
2558 \@@_xmp_property_new:nnnnn
2559 {pdfaid}
2560 {rev}
2561 {Integer}
2562 {internal}
2563 {Revision~year~of~standard}
2564 % \end{macrocode}
2565 % \end{macro}
2566 % \item[pdfuaid] here we need (?) to declare the property
2567 % \enquote{part} and \enquote{rev}.
2568 % \begin{macro}[no-user-doc]{pdfuaid~(schema)}
2569 % \begin{macrocode}
2570 \@@_xmp_schema_new:nnn
2571 {PDF/UA~Universal~Accessibility~Schema}
2572 {pdfuaid}
2573 {http://www.aiim.org/pdfua/ns/id/}
2574 \@@_xmp_property_new:nnnnn
2575 {pdfuaid}
2576 {part}
2577 {Integer}
2578 {internal}
2579 {Part~of~ISO~14289~standard}
2580 \@@_xmp_property_new:nnnnn
2581 {pdfuaid}
2582 {rev}
2583 {Integer}
2584 {internal}
2585 {Revision~of~ISO~14289~standard}
2586 % \end{macrocode}
2587 % \end{macro}
2588 % \item[pdfx] According to [1] not an allowed schema, but it seems
2589 % to validate and allow to set the pdf/X version, \pkg{hyperxmp}
2590 % declares here the properties |GTS_PDFXVersion| and |GTS_PDFXConformance|.
2591 % Ignored as only relevant for older pdf/X version not supported by the pdfmanagement.
2592 %
2593 % \item[pdfxid] we set this so that we
2594 % can add the pdf/X version for pdf/X-4 and higher. This is only set if
2595 % a pdf/X standard is used, see issue \#50
2596 % \begin{macro}[no-user-doc]{pdfxid~(schema)}
2597 % \begin{macrocode}
2598 \cs_new_protected:Npn \@@_xmp_add_pdfxid:
2599 {
2600 \@@_xmp_xmlns_new:nn {pdfxid} {http://www.npes.org/pdfx/ns/id/}
2601 \@@_xmp_schema_new:nnn
2602 {PDF/X~ID~Schema}
2603 {pdfxid}
2604 {http://www.npes.org/pdfx/ns/id/}
2605 \@@_xmp_property_new:nnnnn
2606 {pdfxid}
2607 {GTS_PDFXVersion}
2608 {Text}
2609 {internal}
2610 {ID~of~PDF/X~standard}
2611 }
2612 % \end{macrocode}
2613 % \end{macro}
2614
2615 %\item[Prism]
2616 % \begin{macro}[no-user-doc]{prism~(schema)}
2617 % \begin{macrocode}
2618 \@@_xmp_schema_new:nnn
2619 {PRISM~Basic~Metadata}
2620 {prism}
2621 {http://prismstandard.org/namespaces/basic/3.0/}
2622 \@@_xmp_property_new:nnnnn
2623 {prism}
2624 {complianceProfile}
2625 {Text}
2626 {internal}
2627 {PRISM~specification~compliance~profile~to~which~this~document~adheres}
2628 \@@_xmp_property_new:nnnnn
2629 {prism}
2630 {publicationName}
2631 {Text}
2632 {external}
2633 {Publication~name}
2634 \@@_xmp_property_new:nnnnn
2635 {prism}
2636 {aggregationType}
2637 {Text}
2638 {external}
2639 {Publication~type}
2640 \@@_xmp_property_new:nnnnn
2641 {prism}
2642 {bookEdition}
2643 {Text}
2644 {external}
2645 {Edition~of~the~book~in~which~the~document~was~published}
2646 \@@_xmp_property_new:nnnnn
2647 {prism}
2648 {volume}
2649 {Text}
2650 {external}
2651 {Publication~volume~number}
2652 \@@_xmp_property_new:nnnnn
2653 {prism}
2654 {number}
2655 {Text}
2656 {external}
2657 {Publication~issue~number~within~a~volume}
2658 \@@_xmp_property_new:nnnnn
2659 {prism}
2660 {pageRange}
2661 {Text}
2662 {external}
2663 {Page~range~for~the~document~within~the~print~version~of~its~publication}
2664 \@@_xmp_property_new:nnnnn
2665 {prism}
2666 {issn}
2667 {Text}
2668 {external}
2669 {ISSN~for~the~printed~publication~in~which~the~document~was~published}
2670 \@@_xmp_property_new:nnnnn
2671 {prism}
2672 {eIssn}
2673 {Text}
2674 {external}
2675 {ISSN~for~the~electronic~publication~in~which~the~document~was~published}
2676 \@@_xmp_property_new:nnnnn
2677 {prism}
2678 {isbn}
2679 {Text}
2680 {external}
2681 {ISBN~for~the~publication~in~which~the~document~was~published}
2682 \@@_xmp_property_new:nnnnn
2683 {prism}
2684 {doi}
2685 {Text}
2686 {external}
2687 {Digital~Object~Identifier~for~the~document}
2688 \@@_xmp_property_new:nnnnn
2689 {prism}
2690 {url}
2691 {URL}
2692 {external}
2693 {URL~at~which~the~document~can~be~found}
2694 \@@_xmp_property_new:nnnnn
2695 {prism}
2696 {byteCount}
2697 {Integer}
2698 {internal}
2699 {Approximate~file~size~in~octets}
2700 \@@_xmp_property_new:nnnnn
2701 {prism}
2702 {pageCount}
2703 {Integer}
2704 {internal}
2705 {Number~of~pages~in~the~print~version~of~the~document}
2706 \@@_xmp_property_new:nnnnn
2707 {prism}
2708 {subtitle}
2709 {Text}
2710 {external}
2711 {Document's~subtitle}
2712 % \end{macrocode}
2713 % \end{macro}
2714 % \item[iptc]
2715 % \begin{macro}[no-user-doc]{iptc (schema)}
2716 % \begin{macrocode}
2717 \@@_xmp_schema_new:nnn
2718 {IPTC~Core~Schema}
2719 {Iptc4xmpCore}
2720 {http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/}
2721 \@@_xmp_property_new:nnnnn
2722 {Iptc4xmpCore}
2723 {CreatorContactInfo}
2724 {ContactInfo}
2725 {external}
2726 {Document~creator's~contact~information}
2727 \cs_new_protected:cpn { @@_xmp_schema_Iptc4xmpCore_additions: }
2728 {
2729 \@@_xmp_add_packet_open:nn{pdfaSchema}{valueType}
2730 \@@_xmp_add_packet_open:nn{rdf}{Seq}
2731 \@@_xmp_add_packet_open_attr:nnn{rdf}{li}{rdf:parseType="Resource"}
2732 \@@_xmp_add_packet_line:nnn{pdfaType}{type}{ContactInfo}
2733 \@@_xmp_add_packet_line:nnn{pdfaType}{namespaceURI}
2734 {http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/}
2735 \@@_xmp_add_packet_line:nnn{pdfaType}{prefix}{Iptc4xmpCore}
2736 \@@_xmp_add_packet_line:nnn{pdfaType}{description}
2737 {Basic~set~of~information~to~get~in~contact~with~a~person}
2738 \@@_xmp_add_packet_open:nn{pdfaType}{field}
2739 \@@_xmp_add_packet_open:nn{rdf}{Seq}
2740 \@@_xmp_add_packet_field:nnn{CiAdrCity}{Text}
2741 {Contact~information~city}
2742 \@@_xmp_add_packet_field:nnn{CiAdrCtry}{Text}
2743 {Contact~information~country}
2744 \@@_xmp_add_packet_field:nnn{CiAdrExtadr}{Text}
2745 {Contact~information~address}
2746 \@@_xmp_add_packet_field:nnn{CiAdrPcode}{Text}
2747 {Contact~information~local~postal~code}
2748 \@@_xmp_add_packet_field:nnn{CiAdrRegion}{Text}
2749 {Contact~information~regional~information~such~as~state~or~province}
2750 \@@_xmp_add_packet_field:nnn{CiEmailWork}{Text}
2751 {Contact~information~email~address(es)}
2752 \@@_xmp_add_packet_field:nnn{CiTelWork}{Text}
2753 {Contact~information~telephone~number(s)}
2754 \@@_xmp_add_packet_field:nnn{CiUrlWork}{Text}
2755 {Contact~information~Web~URL(s)}
2756 \@@_xmp_add_packet_close:nn{rdf}{Seq}
2757 \@@_xmp_add_packet_close:nn{pdfaType}{field}
2758 \@@_xmp_add_packet_close:nn{rdf}{li}
2759 \@@_xmp_add_packet_close:nn{rdf}{Seq}
2760 \@@_xmp_add_packet_close:nn{pdfaSchema}{valueType}
2761 }
2762 % \end{macrocode}
2763 % \end{macro}
2764 % \item[jav]: currently ignored
2765 % \item[tdm]
2766 % \begin{macro}[no-user-doc]{tdmrep (schema)}
2767 % \begin{macrocode}
2768 \@@_xmp_schema_new:nnn
2769 {TDMRep}
2770 {tdm}
2771 {http://www.w3.org/ns/tdmrep/}
2772 \@@_xmp_property_new:nnnnn
2773 {tdm}
2774 {reservation}
2775 {Closed~Choice~of~Integer}
2776 {internal}
2777 {TDM~rights~are~reserved~(1)~or~not~reserved~(0)}
2778 \@@_xmp_property_new:nnnnn
2779 {tdm}
2780 {policy}
2781 {URI}
2782 {internal}
2783 {URL~pointing~to~a~TDM~Policy~set~by~the~rightsholder}
2784 % \end{macrocode}
2785 % \end{macro}
2786 %
2787 % \item[declarations] The PDF Declarations mechanism allows creation and
2788 % editing software to declare, via a PDF Declaration, a PDF file to be in
2789 % conformance with a 3rd party specification or profile
2790 % that may not be related to PDF technology. Their specification is for example
2791 % described in \url{https://pdfa.org/wp-content/uploads/2019/09/PDF-Declarations.pdf}.
2792 %
2793 % If declarations are added to the XMP-metadata they need (for pdf/A compliance) a
2794 % schema declaration. We do not add it by default but define here a command to enable
2795 % it. (This can be done in the document preamble as xmp is built only at the end.)
2796 %
2797 %
2798 % \begin{macrocode}
2799 \cs_new_protected:Npn \@@_xmp_schema_enable_pdfd:
2800 {
2801 \@@_xmp_xmlns_new:nn {pdfd}{http://pdfa.org/declarations/}
2802 \@@_xmp_schema_new:nnn
2803 {PDF~Declarations~Schema}
2804 {pdfd}
2805 {http://pdfa.org/declarations/}
2806 \@@_xmp_property_new:nnnnn
2807 {pdfd}
2808 {declarations}
2809 {Bag~declaration}
2810 {external}
2811 {An~unordered~array~of~PDF~Declaration~entries,~where~each~PDF~Declaration~representing~a~statement~of~conformance~with~ an~identified~external~standard~or~profile,~along~with~optional~information~identifying~the~nature~of~the~claim.}
2812 % \end{macrocode}
2813 % the values are complicated so we use the additions: method to add them.
2814 % \begin{macrocode}
2815 \cs_new_protected:cpn { __pdfmeta_xmp_schema_pdfd_additions: }
2816 {
2817 \@@_xmp_add_packet_open:nn{pdfaSchema}{valueType}
2818 \@@_xmp_add_packet_open:nn{rdf}{Seq}
2819 \@@_xmp_add_packet_open_attr:nnn{rdf}{li}{rdf:parseType="Resource"}
2820 \@@_xmp_add_packet_line:nnn{pdfaType}{type}{claim}
2821 \@@_xmp_add_packet_line:nnn{pdfaType}{namespaceURI}
2822 {http://pdfa.org/declarations/}
2823 \@@_xmp_add_packet_line:nnn{pdfaType}{prefix}{pdfd}
2824 \@@_xmp_add_packet_line:nnn{pdfaType}{description}
2825 {A~structure~describing~properties~of~an~individual claim.}
2826 \@@_xmp_add_packet_open:nn{pdfaType}{field}
2827 \@@_xmp_add_packet_open:nn{rdf}{Seq}
2828 \@@_xmp_add_packet_field:nnn{claimReport}{Text}
2829 {A~URL~to~a~report~containing~details~of~the~specific~conformance~claim.}
2830 \@@_xmp_add_packet_field:nnn{claimCredentials}{Text}
2831 {The~claimant's~credentials.}
2832 \@@_xmp_add_packet_field:nnn{claimDate}{Text}
2833 {A~date~identifying~when~the~claim~was~made.}
2834 \@@_xmp_add_packet_field:nnn{claimBy}{Text}
2835 {The~name~of~the~organization~and/or~individual~and/or~software~making~the~claim.}
2836 \@@_xmp_add_packet_close:nn{rdf}{Seq}
2837 \@@_xmp_add_packet_close:nn{pdfaType}{field}
2838 \@@_xmp_add_packet_close:nn{rdf}{li}
2839 \@@_xmp_add_packet_open_attr:nnn{rdf}{li}{rdf:parseType="Resource"}
2840 \@@_xmp_add_packet_line:nnn{pdfaType}{type}{declaration}
2841 \@@_xmp_add_packet_line:nnn{pdfaType}{namespaceURI}
2842 {http://pdfa.org/declarations/}
2843 \@@_xmp_add_packet_line:nnn{pdfaType}{prefix}{pdfd}
2844 \@@_xmp_add_packet_line:nnn{pdfaType}{description}
2845 {A~structure~describing~a~single~PDF~ Declaration~asserting~conformance~with~ an~externally-identified~standard~or~ profile.}
2846 \@@_xmp_add_packet_open:nn{pdfaType}{field}
2847 \@@_xmp_add_packet_open:nn{rdf}{Seq}
2848 \@@_xmp_add_packet_field:nnn{conformsTo}{Text}
2849 {A~property~containing~a~URI~specifying~the~standard~or~profile~by~the~PDF~Declaration.~This~property~is~ intended~to~mirror~the~Dublin~Core~property~dc:conformsTo.}
2850 \@@_xmp_add_packet_field:nnn{claimData}{Bag~claim}
2851 {An~unordered~array~of~claim~data,~where~each~claim~identifies~the~nature~of~the~claim.}
2852 \@@_xmp_add_packet_close:nn{rdf}{Seq}
2853 \@@_xmp_add_packet_close:nn{pdfaType}{field}
2854 \@@_xmp_add_packet_close:nn{rdf}{li}
2855 \@@_xmp_add_packet_close:nn{rdf}{Seq}
2856 \@@_xmp_add_packet_close:nn{pdfaSchema}{valueType}
2857 }
2858 % \end{macrocode}
2859 % the schema should be added only once so disable it after use:
2860 % \begin{macrocode}
2861 \cs_gset_eq:NN \@@_xmp_schema_enable_pdfd: \prg_do_nothing:
2862 }
2863 % \end{macrocode}
2864 %
2865 % \end{description}
2866 % \subsection{The actual user / document data}
2867
2868 % \subsubsection{pdf}
2869 % This builds pdf related the data with the (prefix \enquote{pdf}).
2870 %
2871 % \begin{macro}[int]{\@@_xmp_build_pdf:}
2872 % \begin{macro}[int]{
2873 % Producer/pdfproducer,
2874 % PDFversion}
2875 % \begin{macrocode}
2876 \cs_new_protected:Npn \@@_xmp_build_pdf:
2877 {
2878 % \end{macrocode}
2879 % At first the producer. If not given manually we build it from the exec string
2880 % plus the version number
2881 % \begin{macrocode}
2882 \@@_xmp_add_packet_line_default:nnee
2883 {pdf}{Producer}
2884 {\c_sys_engine_exec_str-\c_sys_engine_version_str}
2885 {\pdfmanagement_get_documentproperty:n{hyperref/pdfproducer}}
2886 % \end{macrocode}
2887 % Now the PDF version
2888 % \begin{macrocode}
2889 \@@_xmp_add_packet_line:nne{pdf}{PDFVersion}{\pdf_version:}
2890 % \end{macrocode}
2891 % \begin{macrocode}
2892 }
2893 % \end{macrocode}
2894 % \end{macro}
2895 % \end{macro}
2896 %
2897 % \subsubsection{xmp}
2898 % This builds the data with the (prefix \enquote{xmp}).
2899 %
2900 % \begin{macro}[int]{\@@_xmp_build_xmp:}
2901 % \begin{macro}[int]{
2902 % CreatorTool/pdfcreator,
2903 % BaseUrl/baseurl}
2904 % \begin{macrocode}
2905 \cs_new_protected:Npn \@@_xmp_build_xmp:
2906 {
2907 % \end{macrocode}
2908 % The creator
2909 % \begin{macrocode}
2910 \@@_xmp_add_packet_line_default:nnee
2911 {xmp}{CreatorTool}
2912 {LaTeX}
2913 { \pdfmanagement_get_documentproperty:n{hyperref/pdfcreator} }
2914 % \end{macrocode}
2915 % The baseurl
2916 % \begin{macrocode}
2917 \@@_xmp_add_packet_line_default:nnee
2918 {xmp}{BaseURL}{}
2919 { \pdfmanagement_get_documentproperty:n{hyperref/baseurl} }
2920 % \end{macrocode}
2921 % CreationDate
2922 % \begin{macrocode}
2923 \@@_xmp_date_get:nNN
2924 {document/creationdate}\l_@@_tmpa_tl\l_@@_tmpa_seq
2925 \@@_xmp_add_packet_line:nne{xmp}{CreateDate}{\@@_xmp_print_date:N\l_@@_tmpa_seq}
2926 \pdfmanagement_add:nne{Info}{CreationDate}{(\l_@@_tmpa_tl)}
2927 % \end{macrocode}
2928 % ModifyDate
2929 % \begin{macrocode}
2930 \@@_xmp_date_get:nNN
2931 {document/moddate}\l_@@_tmpa_tl\l_@@_tmpa_seq
2932 \@@_xmp_add_packet_line:nne{xmp}{ModifyDate}{\@@_xmp_print_date:N\l_@@_tmpa_seq}
2933 \pdfmanagement_add:nne{Info}{ModDate}{(\l_@@_tmpa_tl)}
2934 % \end{macrocode}
2935 % MetadataDate
2936 % \begin{macrocode}
2937 \@@_xmp_date_get:nNN
2938 {hyperref/pdfmetadate}\l_@@_tmpa_tl\l_@@_tmpa_seq
2939 \@@_xmp_add_packet_line:nne{xmp}{MetadataDate}{\@@_xmp_print_date:N\l_@@_tmpa_seq}
2940 % \end{macrocode}
2941 % \begin{macrocode}
2942 }
2943 % \end{macrocode}
2944 % \end{macro}
2945 % \end{macro}
2946 %
2947 % \subsubsection{Standards}
2948 % The metadata for standards are taken from the |pdfstandard| key
2949 % of the |document/metadata| family.
2950 % The values for A-standards are taken from the property, X and UA are currently
2951 % taken from the document container, this should be changed when merging of
2952 % standards are possible.
2953 % \begin{macro}{\@@_xmp_build_standards:}
2954 % \begin{macrocode}
2955 \cs_new_protected:Npn \@@_xmp_build_standards:
2956 {
2957 \@@_xmp_add_packet_line:nne {pdfaid}{part}{\pdfmeta_standard_item:n{level}}
2958 \@@_xmp_add_packet_line:nne
2959 {pdfaid}{conformance}{\pdfmeta_standard_item:n{conformance}}
2960 \int_compare:nNnTF {0\pdfmeta_standard_item:n{level}}<{4}
2961 {\@@_xmp_add_packet_line:nne {pdfaid}{year} {\pdfmeta_standard_item:n{year}}}
2962 {\@@_xmp_add_packet_line:nne {pdfaid}{rev} {\pdfmeta_standard_item:n{year}}}
2963 \@@_xmp_add_packet_line:nne
2964 {pdfxid}{GTS_PDFXVersion}{\pdfmanagement_get_documentproperty:n{document/pdfstandard-X}}
2965 \pdfmanagement_get_documentproperty:nNT {document/pdfstandard-UA}\l_@@_tmpa_tl
2966 {
2967 \@@_xmp_add_packet_line:nne
2968 {pdfuaid}{part}{\exp_last_unbraced:No\use_i:nn \l_@@_tmpa_tl}
2969 \@@_xmp_add_packet_line:nne
2970 {pdfuaid}{rev}{\exp_last_unbraced:No\use_ii:nn \l_@@_tmpa_tl}
2971 }
2972 }
2973 % \end{macrocode}
2974 % \end{macro}
2975 %
2976 % \subsection{Declarations}
2977 % See \url{https://pdfa.org/wp-content/uploads/2019/09/PDF-Declarations.pdf}
2978 %
2979 % \begin{variable}{\g_@@_xmp_pdfd_data_prop}
2980 % This holds the data for declarations.
2981 % \begin{macrocode}
2982 \prop_new:N \g_@@_xmp_pdfd_data_prop
2983 % \end{macrocode}
2984 % \end{variable}
2985 % the main building command used in the xmp generation
2986 % \begin{macro}{\@@_xmp_build_pdfd:}
2987 % \begin{macrocode}
2988 \cs_new_protected:Npn \@@_xmp_build_pdfd:
2989 {
2990 \prop_if_empty:NF\g_@@_xmp_pdfd_data_prop
2991 {
2992 \@@_xmp_add_packet_open:nn{pdfd}{declarations}
2993 \@@_xmp_add_packet_open:nn{rdf}{Bag}
2994 \prop_map_inline:Nn \g_@@_xmp_pdfd_data_prop
2995 {
2996 \@@_xmp_build_pdfd_claim:nn{##1}{##2}
2997 }
2998 \@@_xmp_add_packet_close:nn{rdf}{Bag}
2999 \@@_xmp_add_packet_close:nn{pdfd}{declarations}
3000 }
3001 }
3002 % \end{macrocode}
3003 % \end{macro}
3004 % \begin{macro}{\@@_xmp_build_pdfd_claim:nn}
3005 % This build the xml for one claim. If there is no
3006 % claimData only the conformsTo is output.
3007 % \begin{macrocode}
3008 \cs_new_protected:Npn \@@_xmp_build_pdfd_claim:nn #1#2
3009 {
3010 \@@_xmp_add_packet_open_attr:nnn{rdf}{li}{rdf:parseType="Resource"}
3011 \@@_xmp_add_packet_line:nnn{pdfd}{conformsTo}{#1}
3012 \tl_if_empty:nF {#2}
3013 {
3014 \@@_xmp_add_packet_open:nn{pdfd}{claimData}
3015 \@@_xmp_add_packet_open:nn{rdf}{Bag}
3016 #2
3017 \@@_xmp_add_packet_close:nn{rdf}{Bag}
3018 \@@_xmp_add_packet_close:nn{pdfd}{claimData}
3019 }
3020 \@@_xmp_add_packet_close:nn{rdf}{li}
3021 }
3022 % \end{macrocode}
3023 % \end{macro}
3024 %
3025 % \subsection{Photoshop}
3026 % \begin{macro}{\@@_xmp_build_photoshop:}
3027 % \begin{macrocode}
3028 \cs_new_protected:Npn \@@_xmp_build_photoshop:
3029 {
3030 % \end{macrocode}
3031 % pdfauthortitle/photoshop:AuthorsPosition
3032 % \begin{macrocode}
3033 \@@_xmp_add_packet_line:nne{photoshop}{AuthorsPosition}
3034 { \pdfmanagement_get_documentproperty:n{hyperref/pdfauthortitle} }
3035 % \end{macrocode}
3036 % pdfcaptionwriter/photoshop:CaptionWriter
3037 % \begin{macrocode}
3038 \@@_xmp_add_packet_line:nne{photoshop}{CaptionWriter}
3039 { \pdfmanagement_get_documentproperty:n{hyperref/pdfcaptionwriter} }
3040 % \end{macrocode}
3041 % \begin{macrocode}
3042 }
3043 % \end{macrocode}
3044 % \end{macro}
3045 %
3046
3047 % \subsection{XMP Media Management}
3048
3049 % \begin{macro}{\@@_xmp_build_xmpMM:}
3050 % \begin{macrocode}
3051 \cs_new_protected:Npn \@@_xmp_build_xmpMM:
3052 {
3053 % \end{macrocode}
3054 % pdfdocumentid / xmpMM:DocumentID
3055 % \begin{macrocode}
3056 \str_set:Ne\l_@@_tmpa_str {\pdfmanagement_get_documentproperty:n{hyperref/pdfdocumentid}}
3057 \str_if_empty:NT \l_@@_tmpa_str
3058 {
3059 \@@_xmp_create_uuid:nN
3060 {\jobname\pdfmanagement_get_documentproperty:n{hyperref/pdftitle}}
3061 \l_@@_tmpa_str
3062 }
3063 \@@_xmp_add_packet_line:nnV{xmpMM}{DocumentID}
3064 \l_@@_tmpa_str
3065 % \end{macrocode}
3066 % pdfinstanceid / xmpMM:InstanceID
3067 % \begin{macrocode}
3068 \str_set:Ne\l_@@_tmpa_str {\pdfmanagement_get_documentproperty:n{hyperref/pdfinstanceid}}
3069 \str_if_empty:NT \l_@@_tmpa_str
3070 {
3071 \@@_xmp_create_uuid:nN
3072 {\jobname\l_@@_xmp_currentdate_tl}
3073 \l_@@_tmpa_str
3074 }
3075 \@@_xmp_add_packet_line:nnV{xmpMM}{InstanceID}
3076 \l_@@_tmpa_str
3077 % \end{macrocode}
3078 % pdfversionid/xmpMM:VersionID
3079 % \begin{macrocode}
3080 \@@_xmp_add_packet_line:nne{xmpMM}{VersionID}
3081 { \pdfmanagement_get_documentproperty:n{hyperref/pdfversionid} }
3082 % \end{macrocode}
3083 % pdfrendition/xmpMM:RenditionClass
3084 % \begin{macrocode}
3085 \@@_xmp_add_packet_line:nne{xmpMM}{RenditionClass}
3086 { \pdfmanagement_get_documentproperty:n{hyperref/pdfrendition} }
3087 % \end{macrocode}
3088 % \begin{macrocode}
3089 }
3090 % \end{macrocode}
3091 % \end{macro}
3092 %
3093 % \subsection{Rest of dublin Core data}
3094 %
3095 % \begin{macro}[int]{\@@_xmp_build_dc:}
3096 % \begin{macro}[int]{
3097 % dc:creator/pdfauthor,
3098 % dc:subject/pdfkeywords,
3099 % dc:type/pdftype,
3100 % dc:publisher/pdfpublisher,
3101 % dc:description/pdfsubject,
3102 % dc:language/lang/pdflang,
3103 % dc:identifier/pdfidentifier,
3104 % photoshop:AuthorsPosition/pdfauthortitle,
3105 % photoshop:CaptionWriter/pdfcaptionwriter
3106 % }
3107 % \begin{macrocode}
3108 \cs_new_protected:Npn \@@_xmp_build_dc:
3109 {
3110 % \end{macrocode}
3111 % pdfauthor/dc:creator
3112 % \begin{macrocode}
3113 \@@_xmp_add_packet_list_simple:nnne {dc}{creator}{Seq}
3114 { \pdfmanagement_get_documentproperty:n{hyperref/pdfauthor} }
3115 \int_compare:nNnT {0\pdfmeta_standard_item:n{level}}={1}
3116 { \pdfmanagement_remove:nn{Info}{Author} }
3117 % \end{macrocode}
3118 % pdftitle/dc:title. This is rather complex as we want to support a list
3119 % with different languages.
3120 % \begin{macrocode}
3121 \@@_xmp_add_packet_list:nnne {dc}{title}{Alt}
3122 { \pdfmanagement_get_documentproperty:n{hyperref/pdftitle} }
3123 % \end{macrocode}
3124 % pdfkeywords/dc:subject
3125 % \begin{macrocode}
3126 \@@_xmp_add_packet_list_simple:nnne {dc}{subject}{Bag}
3127 { \pdfmanagement_get_documentproperty:n{hyperref/pdfkeywords} }
3128 \int_compare:nNnT {0\pdfmeta_standard_item:n{level}}={1}
3129 { \pdfmanagement_remove:nn{Info}{Keywords} }
3130 % \end{macrocode}
3131 % pdftype/dc:type
3132 % \begin{macrocode}
3133 \pdfmanagement_get_documentproperty:nNTF { hyperref/pdftype } \l_@@_tmpa_tl
3134 {
3135 \@@_xmp_add_packet_list_simple:nnnV {dc}{type}{Bag}\l_@@_tmpa_tl
3136 }
3137 {
3138 \@@_xmp_add_packet_list_simple:nnnn {dc}{type}{Bag}{Text}
3139 }
3140 % \end{macrocode}
3141 % pdfpublisher/dc:publisher
3142 % \begin{macrocode}
3143 \@@_xmp_add_packet_list_simple:nnne {dc}{publisher}{Bag}
3144 { \pdfmanagement_get_documentproperty:n{hyperref/pdfpublisher} }
3145 % \end{macrocode}
3146 % pdfsubject/dc:description
3147 % \begin{macrocode}
3148 \@@_xmp_add_packet_list:nnne
3149 {dc}{description}{Alt}
3150 {\pdfmanagement_get_documentproperty:n{hyperref/pdfsubject}}
3151 % \end{macrocode}
3152 % lang/pdflang/dc:language
3153 % \begin{macrocode}
3154 \@@_xmp_add_packet_list_simple:nnnV
3155 {dc}{language}{Bag}\l_@@_xmp_doclang_tl
3156 % \end{macrocode}
3157 % pdfidentifier/dc:identifier
3158 % \begin{macrocode}
3159 \@@_xmp_add_packet_line:nne{dc}{identifier}
3160 { \pdfmanagement_get_documentproperty:n{hyperref/pdfidentifier} }
3161 % \end{macrocode}
3162 % pdfdate/dc:date
3163 % \begin{macrocode}
3164 \@@_xmp_date_get:nNN {hyperref/pdfdate}\l_@@_tmpa_tl\l_@@_tmpa_seq
3165 \@@_xmp_add_packet_list_simple:nnne
3166 {dc}{date}{Seq}{\@@_xmp_print_date:N\l_@@_tmpa_seq}
3167 % \end{macrocode}
3168 % The file format
3169 % \begin{macrocode}
3170 \@@_xmp_add_packet_line:nnn{dc}{format}{application/pdf}
3171 % \end{macrocode}
3172 % The source
3173 % \begin{macrocode}
3174 \@@_xmp_add_packet_line_default:nnee
3175 {dc}{source}
3176 { \c_sys_jobname_str.tex }
3177 { \pdfmanagement_get_documentproperty:n{hyperref/pdfsource} }
3178 % \end{macrocode}
3179 % \begin{macrocode}
3180 \@@_xmp_add_packet_list:nnne{dc}{rights}{Alt}
3181 {\pdfmanagement_get_documentproperty:n{hyperref/pdfcopyright}}
3182 % \end{macrocode}
3183 % \begin{macrocode}
3184 }
3185 % \end{macrocode}
3186 % \end{macro}
3187 % \end{macro}
3188 %
3189 % \subsection{xmpRights}
3190 % \begin{macro}{\@@_xmp_build_xmpRights:}
3191 % \begin{macrocode}
3192 \cs_new_protected:Npn \@@_xmp_build_xmpRights:
3193 {
3194 \@@_xmp_add_packet_line:nne
3195 {xmpRights}
3196 {WebStatement}
3197 {\pdfmanagement_get_documentproperty:n{hyperref/pdflicenseurl}}
3198 \@@_xmp_add_packet_line:nne
3199 {xmpRights}
3200 {Marked}
3201 {
3202 \str_case:en {\pdfmanagement_get_documentproperty:n{document/copyright}}
3203 {
3204 {true}{True}
3205 {false}{False}
3206 }
3207 }
3208 }
3209 % \end{macrocode}
3210 % \end{macro}
3211 %
3212 % \subsection{IPTC}
3213 % We want the block and also the resources only if they are actually used. So we pack
3214 % them first in a local variable
3215 % \begin{variable}{\l_@@_xmp_iptc_data_tl}
3216 % \begin{macrocode}
3217 \tl_new:N\l_@@_xmp_iptc_data_tl
3218 % \end{macrocode}
3219 % \end{variable}
3220 % \begin{macro}{\@@_xmp_build_iptc_data:N}
3221 % \begin{macrocode}
3222 \cs_new_protected:Npn \@@_xmp_build_iptc_data:N #1
3223 {
3224 \tl_clear:N #1
3225 \@@_xmp_incr_indent:\@@_xmp_incr_indent:\@@_xmp_incr_indent:\@@_xmp_incr_indent:
3226 \@@_xmp_add_packet_line:nneN
3227 {Iptc4xmpCore}{CiAdrExtadr}
3228 {\pdfmanagement_get_documentproperty:n{hyperref/pdfcontactaddress}}
3229 #1
3230 \@@_xmp_add_packet_line:nneN
3231 {Iptc4xmpCore}{CiAdrCity}
3232 {\pdfmanagement_get_documentproperty:n{hyperref/pdfcontactcity}}
3233 #1
3234 \@@_xmp_add_packet_line:nneN
3235 {Iptc4xmpCore}{CiAdrPcode}
3236 {\pdfmanagement_get_documentproperty:n{hyperref/pdfcontactpostcode}}
3237 #1
3238 \@@_xmp_add_packet_line:nneN
3239 {Iptc4xmpCore}{CiAdrCtry}
3240 {\pdfmanagement_get_documentproperty:n{hyperref/pdfcontactcountry}}
3241 #1
3242 \@@_xmp_add_packet_line:nneN
3243 {Iptc4xmpCore}{CiTelWork}
3244 {\pdfmanagement_get_documentproperty:n{hyperref/pdfcontactphone}}
3245 #1
3246 \@@_xmp_add_packet_line:nneN
3247 {Iptc4xmpCore}{CiEmailWork}
3248 {\pdfmanagement_get_documentproperty:n{hyperref/pdfcontactemail}}
3249 #1
3250 \@@_xmp_add_packet_line:nneN
3251 {Iptc4xmpCore}{CiUrlWork}
3252 {\pdfmanagement_get_documentproperty:n{hyperref/pdfcontacturl}}
3253 #1
3254 \@@_xmp_decr_indent:\@@_xmp_decr_indent:\@@_xmp_decr_indent:\@@_xmp_decr_indent:
3255 }
3256 % \end{macrocode}
3257 % \end{macro}
3258 % \begin{macro}{\@@_xmp_build_iptc:}
3259 % \begin{macrocode}
3260 \cs_new_protected:Npn \@@_xmp_build_iptc:
3261 {
3262 \tl_if_empty:NF\l_@@_xmp_iptc_data_tl
3263 {
3264 \@@_xmp_add_packet_open_attr:nnn
3265 {Iptc4xmpCore}{CreatorContactInfo}{rdf:parseType="Resource"}
3266 \tl_gput_right:Ne\g_@@_xmp_packet_tl { \l_@@_xmp_iptc_data_tl }
3267 \@@_xmp_add_packet_close:nn
3268 {Iptc4xmpCore}{CreatorContactInfo}
3269 }
3270 }
3271 % \end{macrocode}
3272 % \end{macro}
3273 %
3274 % \subsection{Prism}
3275 % \begin{macro}[int]{\@@_xmp_build_prism:}
3276 % \begin{macro}[int]
3277 % {
3278 % complianceProfile,
3279 % prism:subtitle/pdfsubtitle,
3280 % }
3281 % \begin{macrocode}
3282 \cs_new_protected:Npn \@@_xmp_build_prism:
3283 {
3284 % \end{macrocode}
3285 % The compliance profile is a fix value taken from \pkg{hyperxmp}
3286 % \begin{macrocode}
3287 \@@_xmp_add_packet_line:nnn
3288 {prism}{complianceProfile}
3289 {three}
3290 % \end{macrocode}
3291 % the next two values can take an optional language argument.
3292 % First subtitle
3293 % \begin{macrocode}
3294 \@@_xmp_lang_get:eNN
3295 {\pdfmanagement_get_documentproperty:n{hyperref/pdfsubtitle}}
3296 \l_@@_tmpa_tl\l_@@_tmpb_tl
3297 \@@_xmp_add_packet_line_attr:nneV
3298 {prism}{subtitle}
3299 {xml:lang="\l_@@_tmpa_tl"}
3300 \l_@@_tmpb_tl
3301 % \end{macrocode}
3302 % Then publicationName
3303 % \begin{macrocode}
3304 \@@_xmp_lang_get:eNN
3305 {\pdfmanagement_get_documentproperty:n{hyperref/pdfpublication}}
3306 \l_@@_tmpa_tl\l_@@_tmpb_tl
3307 \@@_xmp_add_packet_line_attr:nneV
3308 {prism}{publicationName}
3309 {xml:lang="\l_@@_tmpa_tl"}
3310 \l_@@_tmpb_tl
3311 % \end{macrocode}
3312 % Now the rest
3313 % \begin{macrocode}
3314 \@@_xmp_add_packet_line:nne
3315 {prism}{bookEdition}
3316 {\pdfmanagement_get_documentproperty:n{hyperref/pdfbookedition}}
3317 \@@_xmp_add_packet_line:nne
3318 {prism}{aggregationType}
3319 {\pdfmanagement_get_documentproperty:n{hyperref/pdfpubtype}}
3320 \@@_xmp_add_packet_line:nne
3321 {prism}{volume}
3322 {\pdfmanagement_get_documentproperty:n{hyperref/pdfvolumenum}}
3323 \@@_xmp_add_packet_line:nne
3324 {prism}{number}
3325 {\pdfmanagement_get_documentproperty:n{hyperref/pdfissuenum}}
3326 \@@_xmp_add_packet_line:nne
3327 {prism}{pageRange}
3328 {\pdfmanagement_get_documentproperty:n{hyperref/pdfpagerange}}
3329 \@@_xmp_add_packet_line:nne
3330 {prism}{issn}
3331 {\pdfmanagement_get_documentproperty:n{hyperref/pdfissn}}
3332 \@@_xmp_add_packet_line:nne
3333 {prism}{eIssn}
3334 {\pdfmanagement_get_documentproperty:n{hyperref/pdfeissn}}
3335 \@@_xmp_add_packet_line:nne
3336 {prism}{doi}
3337 {\pdfmanagement_get_documentproperty:n{hyperref/pdfdoi}}
3338 \@@_xmp_add_packet_line:nne
3339 {prism}{url}
3340 {\pdfmanagement_get_documentproperty:n{hyperref/pdfurl}}
3341 % \end{macrocode}
3342 % The page count is take from the previous run or from
3343 % pdfnumpages.
3344 % \begin{macrocode}
3345 \tl_set:Ne \l_@@_tmpa_tl { \pdfmanagement_get_documentproperty:n{hyperref/pdfnumpages} }
3346 \@@_xmp_add_packet_line:nne
3347 {prism}{pageCount}
3348 {\tl_if_blank:VTF \l_@@_tmpa_tl {\PreviousTotalPages}{\l_@@_tmpa_tl}}
3349 % \end{macrocode}
3350 % \begin{macrocode}
3351 }
3352 % \end{macrocode}
3353 % \end{macro}
3354 % \end{macro}
3355
3356 % \subsection{TDM}
3357 % \begin{macro}{\@@_xmp_build_tdm:}
3358 % \begin{macrocode}
3359 \cs_new_protected:Npn \@@_xmp_build_tdm:
3360 {
3361 % \end{macrocode}
3362 % pdftdmreservation/tdm:reservation
3363 % \begin{macrocode}
3364 \@@_xmp_add_packet_line:nne{tdm}{reservation}
3365 { \pdfmanagement_get_documentproperty:n{hyperref/pdftdmreservation} }
3366 % \end{macrocode}
3367 % pdftdmpolicy/tdm:policy
3368 % \begin{macrocode}
3369 \@@_xmp_add_packet_line:nne{tdm}{policy}
3370 { \pdfmanagement_get_documentproperty:n{hyperref/pdftdmpolicy} }
3371 % \end{macrocode}
3372 % \begin{macrocode}
3373 }
3374 % \end{macrocode}
3375 % \end{macro}
3376 %
3377 % \subsection{User additions}
3378 %
3379 % \begin{variable}{\g_@@_xmp_user_packet_str }
3380 % \begin{macrocode}
3381 \tl_new:N \g_@@_xmp_user_packet_tl
3382 % \end{macrocode}
3383 % \end{variable}
3384 % \begin{macro}{\@@_xmp_build_user: }
3385 % \begin{macrocode}
3386 \cs_new_protected:Npn \@@_xmp_build_user:
3387 {
3388 \int_zero:N \l_@@_xmp_indent_int
3389 \g_@@_xmp_user_packet_tl
3390 \int_set:Nn \l_@@_xmp_indent_int {3}
3391 }
3392 % \end{macrocode}
3393 % \end{macro}
3394 % \subsection{Activating the metadata}
3395 % We don't try to get the byte count. So we can put everything
3396 % in the |shipout/lastpage| hook
3397 % \begin{macrocode}
3398 \hook_new:n { pdfmeta/xmp }
3399 \AddToHook{shipout/lastpage}[pdfmanagement-testphase]
3400 {
3401 \bool_if:NT\g_@@_xmp_bool
3402 {
3403 \str_if_exist:NTF\c_sys_timestamp_str
3404 {
3405 \tl_set_eq:NN \l_@@_xmp_currentdate_tl \c_sys_timestamp_str
3406 }
3407 {
3408 \file_get_timestamp:nN{\jobname.log}\l_@@_xmp_currentdate_tl
3409 }
3410 \@@_xmp_date_split:VN\l_@@_xmp_currentdate_tl\l_@@_xmp_currentdate_seq
3411 \hook_use:n { pdfmeta/xmp }
3412 \@@_xmp_build_packet:
3413 \pdf_object_new:n {__pdfmeta/xmp}
3414 \exp_args:No
3415 \__pdf_backend_metadata_stream:n {\g_@@_xmp_packet_tl}
3416 \pdfmanagement_add:nne {Catalog} {Metadata}{\pdf_object_ref:n{__pdfmeta/xmp}}
3417 \bool_if:NT \g_@@_xmp_export_bool
3418 {
3419 \iow_open:Nn\g_tmpa_iow{\g_@@_xmp_export_str.xmpi}
3420 \exp_args:NNo\iow_now:Nn\g_tmpa_iow{\g_@@_xmp_packet_tl}
3421 \iow_close:N\g_tmpa_iow
3422 }
3423 }
3424 }
3425 % \end{macrocode}
3426
3427 % \subsection{User commands}
3428
3429 % \begin{macro}{\pdfmeta_xmp_add:n }
3430 % \begin{macrocode}
3431 \cs_new_protected:Npn \pdfmeta_xmp_add:n #1
3432 {
3433 \tl_gput_right:Nn \g_@@_xmp_user_packet_tl
3434 {
3435 \@@_xmp_add_packet_chunk:n { #1 }
3436 }
3437 }
3438 % \end{macrocode}
3439 % \end{macro}
3440 % \begin{macro}{\pdfmeta_xmp_xmlns_new:nn }
3441 % \begin{macrocode}
3442 \cs_new_protected:Npn \pdfmeta_xmp_xmlns_new:nn #1 #2
3443 {
3444 \prop_if_in:NnTF \g_@@_xmp_xmlns_prop {#1}
3445 {\msg_warning:nnnn{pdfmeta}{xmp-defined}{xmlns~namespace}{#1}}
3446 {\@@_xmp_xmlns_new:nn {#1}{#2}}
3447 }
3448 % \end{macrocode}
3449 % \end{macro}
3450 % \begin{macro}{\pdfmeta_xmp_schema_new:nnn}
3451 % \begin{macrocode}
3452 \cs_set_eq:NN \pdfmeta_xmp_schema_new:nnn \@@_xmp_schema_new:nnn
3453 % \end{macrocode}
3454 % \end{macro}
3455 %
3456 % \begin{macro}{\pdfmeta_xmp_property_new:nnnnn}
3457 % \begin{macrocode}
3458 \cs_set_eq:NN \pdfmeta_xmp_property_new:nnnnn \@@_xmp_property_new:nnnnn
3459 % \end{macrocode}
3460 % \end{macro}
3461 %
3462 % \begin{macro}{\pdfmeta_xmp_add_declaration:n,\pdfmeta_xmp_add_declaration:e}
3463 % \begin{macrocode}
3464 \cs_new_protected:Npn \pdfmeta_xmp_add_declaration:n #1 %conformsTo uri
3465 {
3466 \@@_xmp_schema_enable_pdfd:
3467 \prop_gput:Nnn\g_@@_xmp_pdfd_data_prop{#1}{}
3468 }
3469 \cs_generate_variant:Nn \pdfmeta_xmp_add_declaration:n {e}
3470 % \end{macrocode}
3471 % \end{macro}
3472 % \begin{macro}{\pdfmeta_xmp_add_declaration:nnnnn,\pdfmeta_xmp_add_declaration:ennnn}
3473 % \begin{macrocode}
3474 \cs_new_protected:Npn \pdfmeta_xmp_add_declaration:nnnnn #1#2#3#4#5
3475 %#1=conformsTo uri, #2 claimBy, #3 claimDate #4 claimCredentials #4 claimReport
3476 {
3477 \@@_xmp_schema_enable_pdfd:
3478 \tl_set:Nn \l_@@_tmpa_tl
3479 {
3480 \@@_xmp_add_packet_open_attr:nnn{rdf}{li}{rdf:parseType="Resource"}
3481 \@@_xmp_add_packet_line:nnn{pdfd}{claimBy}{#2}
3482 \@@_xmp_add_packet_line:nnn{pdfd}{claimDate}{#3}
3483 \@@_xmp_add_packet_line:nnn{pdfd}{claimCredentials}{#4}
3484 \@@_xmp_add_packet_line:nnn{pdfd}{claimReport}{#5}
3485 \@@_xmp_add_packet_close:nn{rdf}{li}
3486 }
3487 \prop_get:NnNT \g_@@_xmp_pdfd_data_prop {#1}\l_@@_tmpb_tl
3488 {
3489 \tl_concat:NNN \l_@@_tmpa_tl \l_@@_tmpa_tl \l_@@_tmpb_tl
3490 }
3491 \prop_gput:Nno\g_@@_xmp_pdfd_data_prop{#1}
3492 {
3493 \l_@@_tmpa_tl
3494 }
3495 }
3496 \cs_generate_variant:Nn\pdfmeta_xmp_add_declaration:nnnnn {e,eee}
3497 % \end{macrocode}
3498 % \end{macro}
3499 %
3500 % \subsection{Default declarations}
3501 % The two declarations will be required quite often with ua-2, so we
3502 % provide some interface.
3503
3504 % \begin{macro}{\@@_xmp_wtpdf_reuse_declaration:,\@@_xmp_wtpdf_accessibility_declaration:}
3505 % \begin{macrocode}
3506 \cs_new:Npn \@@_xmp_iso_today:
3507 {
3508 \int_use:N\c_sys_year_int-
3509 \int_compare:nNnT {\c_sys_month_int} < {10}{0} \int_use:N\c_sys_month_int -
3510 \int_compare:nNnT {\c_sys_day_int} < {10}{0} \int_use:N\c_sys_day_int
3511 }
3512 \cs_new_protected:Npn \@@_xmp_wtpdf_reuse_declaration:
3513 {
3514 \pdfmeta_xmp_add_declaration:eeenn
3515 {http://pdfa.org/declarations/wtpdf\c_hash_str reuse1.0}
3516 {LaTeX~Project}
3517 {\@@_xmp_iso_today:}{}{}
3518 }
3519 \cs_new_protected:Npn \@@_xmp_wtpdf_accessibility_declaration:
3520 {
3521 \pdfmeta_xmp_add_declaration:ennnn
3522 {http://pdfa.org/declarations/wtpdf\c_hash_str accessibility1.0}
3523 {LaTeX~Project}
3524 {\@@_xmp_iso_today:}{}{}
3525 }
3526 % \end{macrocode}
3527 % \end{macro}
3528 %
3529 % \begin{macrocode}
3530 %</package>
3531 % \end{macrocode}
3532 %
3533 % \end{implementation}
3534 %
3535 % \PrintIndex