summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-11-04 03:01:54 +0000
committerNorbert Preining <norbert@preining.info>2022-11-04 03:01:54 +0000
commitbe4efcdb2f47821698dc8dbde89722b4f0c2e4b0 (patch)
tree614bb8f887beb481b24b6ad755bbba023fad6845 /macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx
parentc3c9975778ff2848e51f6debf733abe8ca930bd3 (diff)
CTAN sync 202211040301
Diffstat (limited to 'macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx')
-rw-r--r--macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx115
1 files changed, 80 insertions, 35 deletions
diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx
index 8e83708d88..32cfb038db 100644
--- a/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx
+++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdfmeta.dtx
@@ -49,7 +49,7 @@
% }^^A
% }
%
-% \date{Version 0.95s, released 2022-09-26}
+% \date{Version 0.95t, released 2022-11-03}
%
% \maketitle
% \begin{documentation}
@@ -59,27 +59,6 @@
% for PDF standards in general.
% The goal is to collect the requirements and to provide code to check and fulfill them.
%
-% In future is will probably also contain
-% code to setup XMP-metadata.
-% Until then XMP-metadata can be added by one of two mutual incompatible packages:
-% \pkg{hyperxmp} and \pkg{pdfx}. Both
-% packages aren't yet compatible with the new PDF management,
-% but for \pkg{hyperxmp} some patches are provided, so the basic functions works.
-%
-% \begin{NOTE}{UF}
-% This module should not replace both packages.
-% Regarding XMP-metadata its goal
-% is to create a skeleton metadata stream, add some core default values
-% and to define interfaces that allows other packages
-% to add data to this metadata and so to extend them.
-% The problems to solve here are
-% \begin{itemize}
-% \item which tree structure is sensible
-% \item how to escape if needed the input (or which tools are needed to allow
-% the users to correctly escape their input)
-% \item how interface to input data should look
-% \end{itemize}
-% \end{NOTE}
%
% \subsection{Verifying requirements of PDF standards}
%
@@ -408,6 +387,22 @@
% with for example the code needed for ZUGferd,
% they will be added in a second step.
%
+% \subsection{Debug option}
+%
+% The resulting XMP-packet can be written to an external file by activating a debug
+% option
+%
+% \begin{verbatim}
+% \DocumentMetadata{debug={xmp-export}}
+% %or
+% \DocumentMetadata{debug={xmp-export=true}}
+% %or
+% \DocumentMetadata{debug={xmp-export=filename}}
+% \end{verbatim}
+%
+% By default the data are written to \verb+\jobname.xmpi+, if a \texttt{filename} is
+% given, then \verb+filename.xmpi+ is used instead. \verb+xmp-export=false+ deactivates
+% the export.
%
% \subsection{Encoding and escaping}
%
@@ -567,7 +562,7 @@
% \begin{macrocode}
%<@@=pdfmeta>
%<*header>
-\ProvidesExplPackage{l3pdfmeta}{2022-09-26}{0.95s}
+\ProvidesExplPackage{l3pdfmeta}{2022-11-03}{0.95t}
{PDF-Standards---LaTeX PDF management testphase bundle}
%</header>
% \end{macrocode}
@@ -1215,6 +1210,31 @@
xmp .bool_gset:N = \g_@@_xmp_bool
}
% \end{macrocode}
+% XMP debugging option
+% \begin{macrocode}
+\bool_new:N \g_@@_xmp_export_bool
+\str_new:N \g_@@_xmp_export_str
+
+\keys_define:nn { document / metadata }
+ {
+ ,debug / xmp-export .choice:
+ ,debug / xmp-export / true .code:n=
+ {
+ \bool_gset_true:N \g_@@_xmp_export_bool
+ \str_gset_eq:NN \g_@@_xmp_export_str \c_sys_jobname_str
+ }
+ ,debug / xmp-export / false .code:n =
+ {
+ \bool_gset_false:N \g_@@_xmp_export_bool
+ }
+ ,debug / xmp-export /unknown .code:n =
+ {
+ \bool_gset_true:N \g_@@_xmp_export_bool
+ \str_gset:Nn \g_@@_xmp_export_str { #1 }
+ }
+ ,debug / xmp-export .default:n = true
+ }
+% \end{macrocode}
% \subsection{Messages}
% \begin{macrocode}
\msg_new:nnn{pdfmeta}{namespace-defined}{The~xmlns~namespace~`#1`~is~already~declared}
@@ -1598,6 +1618,26 @@
% \end{macrocode}
% \end{macro}
% Some data are stored as unordered (Bag) or ordered lists (Seq) or (Alt).
+% The first variant are for simple text without language support:
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_xmp_add_packet_list_simple:nnnn #1 #2 #3 #4
+ %#1 prefix, #2 name, #3 type (Seq/Bag/Alt) #4 a clist
+ {
+ \clist_if_empty:nF { #4 }
+ {
+ \@@_xmp_add_packet_open:nn {#1}{#2}
+ \@@_xmp_add_packet_open:nn {rdf}{#3}
+ \clist_map_inline:nn {#4}
+ {
+ \@@_xmp_add_packet_line:nnn
+ {rdf}{li}{##1}
+ }
+ \@@_xmp_add_packet_close:nn{rdf}{#3}
+ \@@_xmp_add_packet_close:nn {#1}{#2}
+ }
+ }
+\cs_generate_variant:Nn \@@_xmp_add_packet_list_simple:nnnn {nnnV,nnne}
+% \end{macrocode}
% Here we check also for the language.
% \begin{macrocode}
\cs_new_protected:Npn \@@_xmp_add_packet_list:nnnn #1 #2 #3 #4
@@ -2270,14 +2310,13 @@
% \end{macrocode}
% pdftype/dc:type
% \begin{macrocode}
- \tl_if_blank:eTF { \GetDocumentProperties{hyperref/pdftype} }
- {
- \@@_xmp_add_packet_list:nnne {dc}{type}{Bag}{Text}
- }
- {
- \@@_xmp_add_packet_list:nnne {dc}{type}{Bag}
- { { \GetDocumentProperties{hyperref/pdftype} }}
- }
+ \pdfmanagement_get_documentproperties:nNTF { hyperref/pdftype } \l_@@_tmpa_tl
+ {
+ \@@_xmp_add_packet_list_simple:nnnV {dc}{type}{Bag}\l_@@_tmpa_tl
+ }
+ {
+ \@@_xmp_add_packet_list_simple:nnnn {dc}{type}{Bag}{Text}
+ }
% \end{macrocode}
% pdfpublisher/dc:publisher
% \begin{macrocode}
@@ -2292,8 +2331,8 @@
% \end{macrocode}
% lang/pdflang/dc:language
% \begin{macrocode}
- \@@_xmp_add_packet_list:nnne {dc}{language}{Bag}
- { \l_@@_xmp_doclang_tl }
+ \@@_xmp_add_packet_list_simple:nnnV
+ {dc}{language}{Bag}\l_@@_xmp_doclang_tl
% \end{macrocode}
% pdfidentifier/dc:identifier
% \begin{macrocode}
@@ -2303,8 +2342,8 @@
% pdfdate/dc:date
% \begin{macrocode}
\@@_xmp_date_get:nNN {hyperref/pdfdate}\l_@@_tmpa_tl\l_@@_tmpa_seq
- \@@_xmp_add_packet_list:nnne {dc}{date}{Seq}
- {\@@_xmp_print_date:N\l_@@_tmpa_seq}
+ \@@_xmp_add_packet_list_simple:nnne
+ {dc}{date}{Seq}{\@@_xmp_print_date:N\l_@@_tmpa_seq}
% \end{macrocode}
% The file format
% \begin{macrocode}
@@ -2515,6 +2554,12 @@
\exp_args:No
\__pdf_backend_metadata_stream:n {\g_@@_xmp_packet_tl}
\pdfmanagement_add:nnx {Catalog} {Metadata}{\pdf_object_ref_last:}
+ \bool_if:NT \g_@@_xmp_export_bool
+ {
+ \iow_open:Nn\g_tmpa_iow{\g_@@_xmp_export_str.xmpi}
+ \exp_args:NNo\iow_now:Nn\g_tmpa_iow{\g_@@_xmp_packet_tl}
+ \iow_close:N\g_tmpa_iow
+ }
}
}
% \end{macrocode}