texlive[43316] Master/texmf-dist: hyperxmp (22feb17)

commits+karl at tug.org commits+karl at tug.org
Thu Feb 23 23:00:12 CET 2017


Revision: 43316
          http://tug.org/svn/texlive?view=revision&revision=43316
Author:   karl
Date:     2017-02-23 23:00:11 +0100 (Thu, 23 Feb 2017)
Log Message:
-----------
hyperxmp (22feb17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/hyperxmp/README
    trunk/Master/texmf-dist/doc/latex/hyperxmp/hyperxmp.pdf
    trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx
    trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.ins
    trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty

Modified: trunk/Master/texmf-dist/doc/latex/hyperxmp/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/hyperxmp/README	2017-02-23 21:59:58 UTC (rev 43315)
+++ trunk/Master/texmf-dist/doc/latex/hyperxmp/README	2017-02-23 22:00:11 UTC (rev 43316)
@@ -51,7 +51,7 @@
 Copyright and license
 =====================
 
-Copyright (C) 2016 Scott Pakin
+Copyright (C) 2017 Scott Pakin
 
 This file may be distributed and/or modified under the conditions of
 the LaTeX Project Public License, either version 1.3c of this license

Modified: trunk/Master/texmf-dist/doc/latex/hyperxmp/hyperxmp.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx	2017-02-23 21:59:58 UTC (rev 43315)
+++ trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx	2017-02-23 22:00:11 UTC (rev 43316)
@@ -1,6 +1,6 @@
 % \iffalse meta-comment
 %
-% Copyright (C) 2016 by Scott Pakin <scott+hyxmp at pakin.org>
+% Copyright (C) 2017 by Scott Pakin <scott+hyxmp at pakin.org>
 % -------------------------------------------------------
 %
 % This file may be distributed and/or modified under the
@@ -22,7 +22,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{hyperxmp}
 %<*package>
-    [2016/07/04 v3.0 Store hyperref metadata in XMP format]
+    [2017/02/23 v3.2 Store hyperref metadata in XMP format]
 %</package>
 %
 %<*driver>
@@ -54,7 +54,7 @@
   pdftitle={The hyperxmp package},
   pdfsubject={LaTeX2e support for XMP metadata},
   pdfkeywords={LaTeX, embedded metadata, XMP, PDF, copyright, license, comments},
-  pdfcopyright={Copyright (C) 2016, Scott Pakin},
+  pdfcopyright={Copyright (C) 2017, Scott Pakin},
   pdflicenseurl={http://www.latex-project.org/lppl/},
   pdfcaptionwriter={Scott Pakin},
   pdfcontactemail={scott+hyxmp at pakin.org},
@@ -81,7 +81,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{1593}
+% \CheckSum{1775}
 %
 % \CharacterTable
 %  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -366,8 +366,10 @@
 % \begin{itemize}
 %   \item \optname{baseurl}
 %   \item \optname{pdfauthor}
+%   \item \optname{pdfcreationdate}
 %   \item \optname{pdfkeywords}
 %   \item \optname{pdflang}
+%   \item \optname{pdfmoddate}
 %   \item \optname{pdfproducer}
 %   \item \optname{pdfsubject}
 %   \item \optname{pdftitle}
@@ -394,6 +396,7 @@
 %   \item \optname{pdfcopyright}
 %   \item \optname{pdfdate}
 %   \item \optname{pdflicenseurl}
+%   \item \optname{pdfmetadate}
 %   \item \optname{pdfmetalang}
 %   \item \optname{pdftype}
 % \end{itemize}
@@ -404,10 +407,10 @@
 % conjunction with \pkgname{hyperref}'s \optname{pdfa} option to claim a
 % particular \acro{PDF/A} standard by which the document abides.  They
 % default to \optname{pdfapart}=|1| and \optname{pdfaconformance}=|B|,
-% indicating the \acro{PDF/A}-1B standard.  These can be changed (with
-% caution) to assert that the document abides by a different standard
-% (e.g.,~\acro{PDF/A}-2U).
-
+% indicating the \acro{PDF/A}-\textsc{1b} standard.  These can be
+% changed (with caution) to assert that the document abides by a
+% different standard (e.g.,~\acro{PDF/A}-\textsc{2u}).
+%
 % \optname{pdfauthortitle} indicates the primary author's position or
 % title.  \optname{pdfcaptionwriter} specifies the name of the person
 % who added the metadata to the document.  The next eight items describe
@@ -424,37 +427,57 @@
 % \optname{pdfcontacturl} is the contact's \acro{URL} (or multiple,
 % comma-separated \acro{URL}s).
 %
-% \optname{pdfcopyright} defines the copyright text.  \optname{pdfdate}
-% specifies the document date.  It is analogous to the \LaTeX\ |\date|
-% command, and, like |\date|, defaults to the date the document was
-% built.  However, \optname{pdfdate} must be specified in
-% \textsc{yyyy}|-|\textsc{mm}|-|\textsc{dd}|T|hh|:|mm|:|ss|.|ff|+|\textsc{tt}|:|tt
-% format as per the W3C's recommendation~\cite{Wolf1997:date-time}.  For
-% example, 14~hours, 15~minutes, 9.26~seconds past midnight
-% U.S. Mountain Daylight Time (UTC-6) on the 23rd day of September in the
-% year~2014 should be written as \texttt{2014-09-23T14:15:09.26-06:00}.
-% This can be truncated to \texttt{2014-09-23T14:15:09-06:00} or
-% \texttt{2014-09-23T14:15-06:00} or \texttt{2014-09-23} or
-% \texttt{2014-09} or \texttt{2014} but no other subsets.
-% \pkgname{hyperxmp} does not validate \optname{pdfdate}'s argument, but
-% an invalid format may confuse a \acro{PDF} reader.
+% \acro{XMP} metadata can include a number of dates (in fact,
+% timestamps, as they include both date and time components).
+% \optname{pdfdate} specifies the document date.  It is analogous to the
+% \LaTeX\ |\date| command, and, like |\date|, defaults to the date the
+% document was built.  It must be specified in either \acro{XMP}
+% format~\cite{Adobe2012:XMP} or \acro{PDF} format~\cite{Adobe2008:PDF}.
+% \acro{XMP} dates are written in the form
+% \textsc{yyyy}|-|\textsc{mm}|-|\textsc{dd}|T|hh|:|mm|:|ss|+|\textsc{tt}|:|tt.\footnote{Although
+%   allowed by \acro{XMP}, \pkgname{hyperxmp} does not currently accept
+%   fractions of a second in timestamps.}  A W3C
+% recommendation~\cite{Wolf1997:date-time} discusses this format in more
+% detail, but as an example, 14~hours, 15~minutes, 9~seconds past
+% midnight U.S. Mountain Daylight Time (UTC-6) on the 23rd day of
+% September in the year~2014 should be written as
+% \texttt{2014-09-23T14:15:09-06:00}.  This can be truncated (with loss
+% of information) to \texttt{2014-09-23T14:15:09} or
+% \texttt{2014-09-23T14:15} or \texttt{2014-09-23} or \texttt{2014-09}
+% or \texttt{2014} but no other subsets.  \acro{PDF} dates are written
+% in the form |D:|\textsc{yyyymmdd}hhmmss|+|\textsc{tt}|'|tt|'|.  The
+% same date in the preceding example would be written as
+% \texttt{D:20140923141509-06'00'} in \acro{PDF} format.
 %
+% The document's creation date, modification date, and metadata date are
+% normally set automatically, but \optname{pdfcreationdate},
+% \optname{pdfmoddate}, and \optname{pdfmetadate} can be used to
+% override the defaults.  Like \optname{pdfdate}, \optname{pdfmetadate}
+% can be specified in either \acro{XMP} or \acro{PDF} format.  However,
+% because \pkgname{hyperref} defines \optname{pdfcreationdate} and
+% \optname{pdfmoddate} and expects these to be written as \acro{PDF}
+% dates, \pkgname{hyperxmp} concomitantly accepts these two dates only
+% in \acro{PDF} format as well.  Note that it's rare that a document
+% would need to specify any of \optname{pdfcreationdate},
+% \optname{pdfmoddate}, or \optname{pdfmetadate}.
+%
+% \optname{pdfcopyright} defines the copyright text, and
 % \optname{pdflicenseurl} identifies a \acro{URL} that points to the
 % document's license agreement.
-%   \optname{pdfmetalang} indicates the
-% natural language in which the metadata is written, typically as an
-% \acro{IETF} language tag~\cite{IANA2011:lang-tags}, for example,
-% ``|en|'' for English, ``|en-US|'' for specifically United States
-% English, ``|de|'' for German, and so forth.  If \optname{pdfmetalang}
-% is not specified, \pkgname{hyperxmp} assumes the metadata language is
-% the same as the document language (\pkgname{hyperref}'s
-% \optname{pdflang} option).  If neither \optname{pdfmetalang} nor
-% \optname{pdflang} is specified, \pkgname{hyperxmp} uses only
-% ``|x-default|'' as the metadata language.  Note that ``|x-default|''
-% metadata is always included in addition to the specified metadata
-% language, as the user reading the document may not have specified a
-% language preference.
 %
+% \optname{pdfmetalang} indicates the natural language in which the
+% metadata is written, typically as an \acro{IETF} language
+% tag~\cite{IANA2011:lang-tags}, for example, ``|en|'' for English,
+% ``|en-US|'' for specifically United States English, ``|de|'' for
+% German, and so forth.  If \optname{pdfmetalang} is not specified,
+% \pkgname{hyperxmp} assumes the metadata language is the same as the
+% document language (\pkgname{hyperref}'s \optname{pdflang} option).  If
+% neither \optname{pdfmetalang} nor \optname{pdflang} is specified,
+% \pkgname{hyperxmp} uses only ``|x-default|'' as the metadata language.
+% Note that ``|x-default|'' metadata is always included in addition to
+% the specified metadata language, as the user reading the document may
+% not have specified a language preference.
+%
 % \optname{pdftype} describes the type of document being produced.  This
 % refers to ``the nature or genre of the resource''~\cite{Adobe2012:XMP}
 % such as ``|poem|'', ``|novel|'' or ``|working paper|'', as opposed to
@@ -956,13 +979,55 @@
 % \end{macro}
 %
 % \begin{macro}{\@pdfdatetime}
-% Prepare to store the document's date and (optionally) time.
+% Prepare to store the document's date and (optionally) time.  Whether
+% specified by the author in \acro{XMP} format or \acro{PDF} format
+% (cf.~Section~\ref{sec:date-manip}) we always store |\@pdfdatetime| as
+% an \acro{XMP}-format string.
 %    \begin{macrocode}
 \def\@pdfdatetime{}
-\define at key{Hyp}{pdfdate}{\hyxmp at pdfstringdef\@pdfdatetime{#1}}
+\define at key{Hyp}{pdfdate}{%
+  \begingroup
+    \Hy at unicodefalse
 %    \end{macrocode}
+% \begin{macro}{\next}
+% Expand \optname{pdfdate}'s argument and convert it to \acro{XMP} format.
+%    \begin{macrocode}
+    \edef\next{%
+      \noexpand\hyxmp at pdfstringdef\noexpand\@pdfdatetime{%
+        \noexpand\hyxmp at as@xmp at date{#1}}%
+    }%
+    \next
+  \endgroup
+}
+%    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
+% \begin{macro}{\@pdfmetadatetime}
+% Prepare to store the document's metadata date and (optionally) time.
+% Whether specified by the author in \acro{XMP} format or \acro{PDF}
+% format (cf.~Section~\ref{sec:date-manip}) we always store
+% |\@pdfmetadatetime| as an \acro{XMP}-format string.
+%    \begin{macrocode}
+\def\@pdfmetadatetime{}
+\define at key{Hyp}{pdfmetadate}{%
+  \begingroup
+    \Hy at unicodefalse
+%    \end{macrocode}
+% \begin{macro}{\next}
+% Expand \optname{pdfmetadate}'s argument and convert it to \acro{XMP} format.
+%    \begin{macrocode}
+    \edef\next{%
+      \noexpand\hyxmp at pdfstringdef\noexpand\@pdfmetadatetime{%
+        \noexpand\hyxmp at as@xmp at date{#1}}%
+    }%
+    \next
+  \endgroup
+}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \begin{macro}{\@pdfcopyright}
 % Prepare to store the document's copyright statement.
 %    \begin{macrocode}
@@ -1330,13 +1395,16 @@
     \@pdfcontactregion
     \@pdfcontacturl
     \@pdfcopyright
-    \@pdftype
+    \@pdfcreationdate
     \@pdfdatetime
     \@pdfkeywords
     \@pdflang
     \@pdflicenseurl
+    \@pdfmetadatetime
+    \@pdfmoddate
     \@pdfsubject
     \@pdftitle
+    \@pdftype
   }%
   \ifx\hyxmp at concated@metadata\@empty
     \PackageWarningNoLine{hyperxmp}{%
@@ -1596,6 +1664,354 @@
 % \end{macro}
 %
 %
+% \subsubsection{Date manipulation}
+% \label{sec:date-manip}
+%
+% \pkgname{hyperxmp} needs to manipulate two types of date (really,
+% timestamp) formats: \acro{PDF} format and \acro{XMP} format.
+% \acro{PDF} timestamps are of the form
+% ``|D:|\textsc{yyyymmdd}hhmmss|+|\textsc{tt}|'|tt|'|''
+% \makeatletter
+% \@ifundefined{pdffeedback}{^^A
+%   \@ifundefined{pdfcreationdate}{^^A
+%   }{^^A
+%     (e.g.,~\texttt{\pdfcreationdate})^^A
+%   }^^A
+% }{^^A
+%   (e.g.,~\texttt{\pdffeedback creationdate})^^A
+% }
+% \makeatother
+% ~\cite{Adobe2008:PDF}, while \acro{XMP} timestamps are of the form
+% ``\textsc{yyyy}|-|\textsc{mm}|-|\textsc{dd}|T|hh|:|mm|:|ss|+|\textsc{tt}|:|tt''
+% \makeatletter
+% \@ifundefined{pdffeedback}{^^A
+%   \@ifundefined{pdfcreationdate}{^^A
+%     \unskip
+%   }{^^A
+%     (e.g.,~\texttt{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate})^^A
+%   }^^A
+% }{^^A
+%   (e.g.,~\texttt{\expandafter\hyxmp at pdf@to at xmp@date\pdffeedback creationdate})^^A
+% }^^A
+% \makeatother
+% ~\cite{Adobe2012:XMP}.  The |\hyxmp at as@pdf at date| and
+% |\hyxmp at as@xmp at date| macros defined in this section facilitate
+% timestamp conversions to \acro{PDF} and \acro{XMP} formats,
+% respectively.
+%
+% \begin{macro}{\hyxmp at first@char}
+% \begin{macro}{\hyxmp at first@char at i}
+% Return the first character of a string.  This macro is fully expandable.
+%    \begin{macrocode}
+\def\hyxmp at first@char#1{\hyxmp at first@char at i#1\relax}
+\def\hyxmp at first@char at i#1#2\relax{#1}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at as@xmp at date}
+% If necessary, convert a timestamp to \acro{XMP} format.  That is, if
+% the timestamp is in \acro{PDF} format, convert it; otherwise, leave it
+% unmodified.  This macro is fully expandable.
+% \changes{v3.2}{2017/02/20}{Added this macro}
+%    \begin{macrocode}
+\def\hyxmp at as@xmp at date#1{%
+  \expandafter\ifx\hyxmp at first@char at i#1\relax D%
+    \hyxmp at pdf@to at xmp@date{#1}%
+  \else
+    #1%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at pdf@to at xmp@date}
+% Convert a timestamp from \acro{PDF} format to \acro{XMP} format.  This
+% macro is fully expandable.
+% \changes{v2.4}{2013/12/24}{Added this macro}
+%    \begin{macrocode}
+\def\hyxmp at pdf@to at xmp@date#1:#2#3#4#5#6#7#8#9{%
+  #2#3#4#5-#6#7-#8#9%
+  \hyxmp at parse@time
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at parse@time}
+% This is a helper function for |\hyxmp at pdf@to at xmp@date|.
+% |\hyxmp at pdf@to at xmp@date| proper parses only the year, month, and day
+% then calls |\hyxmp at parse@time|.  |\hyxmp at parse@time| parses the
+% hours, minutes, and seconds then calls |\hyxmp at parse@tz at char|.
+% \changes{v2.4}{2013/12/24}{Added this macro}
+%    \begin{macrocode}
+\def\hyxmp at parse@time#1#2#3#4#5#6{%
+  T#1#2:#3#4:#5#6%
+  \hyxmp at parse@tz at char
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at parse@tz at char}
+% This is another helper function for |\hyxmp at pdf@to at xmp@date|.  So far,
+% the date and time have been parsed.  |\hyxmp at parse@tz at char| parses the
+% first character of the timezone descriptor.  This can be one of
+% ``|+|'' for eastern timezones (\mbox{UTC$+x$}, including Asia,
+% Oceania, and most of Europe), ``|-|'' for western timezones
+% (\mbox{UTC$-x$}, primarily the Americas), or ``|Z|'' for Zulu time
+% (\mbox{UTC$+0$}).  Timezones beginning with ``|+|'' or ``|-|'' are
+% followed by an offset in hours and minutes (parsed by
+% |\hyxmp at parse@tz|; timezones beginning with ``|Z|'' are not.
+% \changes{v2.4}{2013/12/24}{Added this macro}
+%    \begin{macrocode}
+\def\hyxmp at parse@tz at char#1{%
+  #1%
+  \ifx#1-%
+    \expandafter\hyxmp at parse@tz
+  \else
+    \ifx#1+%
+      \expandafter\hyxmp at parse@tz
+    \fi
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at parse@tz}
+% This is the final helper function for |\hyxmp at pdf@to at xmp@date|.  It
+% parses the piece of the timezone comprising the offset from
+% Coordinated Universal Time, measured in hours and minutes.
+% \changes{v2.4}{2013/12/24}{Added this macro}
+%    \begin{macrocode}
+\def\hyxmp at parse@tz#1'#2'{%
+  #1:#2%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at as@pdf at date}
+% If necessary, convert a timestamp to \acro{PDF} format.  That is, if
+% the timestamp is in \acro{XMP} format, convert it; otherwise, leave it
+% unmodified.  This macro is fully expandable.
+% \changes{v3.2}{2017/02/20}{Added this macro}
+%    \begin{macrocode}
+\def\hyxmp at as@pdf at date#1{%
+  \expandafter\ifx\hyxmp at first@char at i#1\relax D%
+    #1%
+  \else
+    \hyxmp at xmp@to at pdf@date{#1}%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at xmp@to at pdf@date}
+% Convert a timestamp from \acro{XMP} format to \acro{PDF} format.  This
+% macro is fully expandable.
+% \changes{v2.4}{2013/12/24}{Added this macro}
+%    \begin{macrocode}
+\def\hyxmp at xmp@to at pdf@date#1{%
+  D:\hyxmp at xmp@to at pdf@date at i#1\relax\relax
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at xmp@to at pdf@date at i}
+% Parse the year for |\hyxmp at xmp@to at pdf@date|.
+%    \begin{macrocode}
+\def\hyxmp at xmp@to at pdf@date at i#1#2#3#4#5#6{%
+  #1#2#3#4%
+  \ifx#5-%
+    \expandafter\hyxmp at xmp@to at pdf@date at ii\expandafter#6%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at xmp@to at pdf@date at ii}
+% Parse the month for |\hyxmp at xmp@to at pdf@date|.
+%    \begin{macrocode}
+\def\hyxmp at xmp@to at pdf@date at ii#1#2#3#4{%
+  #1#2%
+  \ifx#3-%
+    \expandafter\hyxmp at xmp@to at pdf@date at iii\expandafter#4%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at xmp@to at pdf@date at iii}
+% Parse the day for |\hyxmp at xmp@to at pdf@date|.
+%    \begin{macrocode}
+\def\hyxmp at xmp@to at pdf@date at iii#1#2#3#4{%
+  #1#2%
+  \ifx#3T%
+    \expandafter\hyxmp at xmp@to at pdf@date at iv\expandafter#4%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at xmp@to at pdf@date at iv}
+% Parse the hour for |\hyxmp at xmp@to at pdf@date|.
+%    \begin{macrocode}
+\def\hyxmp at xmp@to at pdf@date at iv#1#2#3#4{%
+  #1#2%
+  \ifx#3:%
+    \expandafter\hyxmp at xmp@to at pdf@date at v\expandafter#4%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at xmp@to at pdf@date at v}
+% Parse the minute for |\hyxmp at xmp@to at pdf@date|.
+%    \begin{macrocode}
+\def\hyxmp at xmp@to at pdf@date at v#1#2#3#4{%
+  #1#2%
+  \ifx#3:%
+    \expandafter\hyxmp at xmp@to at pdf@date at vi\expandafter#4%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at gobbletwo}
+% This is exactly the same as \LaTeXe's |\@gobbletwo| but needs to be a
+% different literal for |\hyxmp at xmp@to at pdf@date at vii|'s pattern-matching
+% to work.
+%    \begin{macrocode}
+\let\@hyxmp at gobbletwo=\@gobbletwo
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at xmp@to at pdf@date at vi}
+% Parse the second for |\hyxmp at xmp@to at pdf@date|.  The challenge here is
+% that we need to handle four cases for the character following the
+% seconds---``|+|'', ``|-|'', ``|Z|'', and no character---without sacrificing
+% expandability.  Our tricky solution is to insert a |\@gobbletwo| as a
+% sentinel and let |\hyxmp at xmp@to at pdf@date at vi| discard everything up to
+% that sentinel (i.e.,~all the other conditionals).
+%    \begin{macrocode}
+\def\hyxmp at xmp@to at pdf@date at vi#1#2#3#4{%
+  #1#2%
+  \ifx#3+%
+    +\expandafter\hyxmp at xmp@to at pdf@date at vii
+  \fi
+  \ifx#3-%
+    -\expandafter\hyxmp at xmp@to at pdf@date at vii
+  \fi
+  \ifx#3Z%
+    Z%
+  \fi
+  \ifx#3\relax
+    \expandafter\@hyxmp at gobbletwo
+  \fi
+  \@gobbletwo #4%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at xmp@to at pdf@date at vii}
+% Parse the time-zone hours for |\hyxmp at xmp@to at pdf@date|.
+%    \begin{macrocode}
+\def\hyxmp at xmp@to at pdf@date at vii#1\@gobbletwo#2#3#4#5{%
+  #2#3%
+  \ifx#4:%
+    \expandafter\hyxmp at xmp@to at pdf@date at viii\expandafter#5%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at xmp@to at pdf@date at viii}
+% Parse the time-zone minutes for |\hyxmp at xmp@to at pdf@date|.
+%    \begin{macrocode}
+\def\hyxmp at xmp@to at pdf@date at viii#1#2#3#4{%
+  '#1#2'%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at today@define}
+% Use \TeX\ primitives to define a given macro as today's date in
+% \textsc{yyyy}-\textsc{mm}-\textsc{dd}|T|hh|:|mm format.
+% \changes{v2.4}{2013/12/21}{Added this macro}
+% \changes{v3.0}{2016/07/03}{Modified to accept the name of a macro
+%   to define}
+% \changes{v3.2}{2017/02/21}{Modified to include hours and minutes}
+%    \begin{macrocode}
+\def\hyxmp at today@define#1{%
+%    \end{macrocode}
+% The date is a straightforward representation of \TeX's |\year|,
+% |\month|, and |\day| primitives, with the latter two zero-padded to
+% two digits apiece.
+%    \begin{macrocode}
+  \xdef#1{\the\year}%
+  \ifnum\month<10
+    \xdef#1{#1-0\the\month}%
+  \else
+    \xdef#1{#1-\the\month}%
+  \fi
+  \ifnum\day<10
+    \xdef#1{#1-0\the\day}%
+  \else
+    \xdef#1{#1-\the\day}%
+  \fi
+%    \end{macrocode}
+% \TeX\ does not provide the time in terms of separate hours and minutes
+% but rather as the total number of minutes since midnight (|\time|).
+% There's no mechanism in \TeX\ to query the number of seconds since
+% midnight or the timezone so we omit those fields when defining
+% macro~|#1|.
+%    \begin{macrocode}
+  \@tempcnta=\time
+  \divide\@tempcnta by 60%
+  \ifnum\@tempcnta<10%
+    \xdef#1{#1T0\the\@tempcnta}%
+  \else
+    \xdef#1{#1T\the\@tempcnta}%
+  \fi
+  \multiply\@tempcnta by -60%
+  \advance\@tempcnta by \time
+  \ifnum\@tempcnta<10%
+    \xdef#1{#1:0\the\@tempcnta}%
+  \else
+    \xdef#1{#1:\the\@tempcnta}%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\hyxmp at today}
+% Define |\hyxmp at today| as the current date and (if available) time and
+% timezone in \acro{XMP} \xmpterm{Date} format~\cite{Adobe2012:XMP}.
+% \changes{v2.4}{2013/12/24}{Modified the code to parse the time and
+%   timezone from \texttt{\string\string\string\pdfcreationdate}, as
+%   proposed by Florian Breitwieser}
+%    \begin{macrocode}
+\@ifundefined{pdffeedback}{%
+  \@ifundefined{pdfcreationdate}{%
+%    \end{macrocode}
+% Case 1: Neither |\pdffeedback| nor |\pdfcreationdate| is defined
+% (\XeLaTeX\ and regular \LaTeX).
+%    \begin{macrocode}
+    \hyxmp at today@define\hyxmp at today
+  }{%
+%    \end{macrocode}
+% Case 2: |\pdfcreationdate| is defined (\pdfLaTeX\ and pre-0.85 \LuaLaTeX).
+%    \begin{macrocode}
+    \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate}%
+  }%
+}{%
+%    \end{macrocode}
+% Case 3: |\pdffeedback| is defined (\LuaLaTeX~0.85+).
+%    \begin{macrocode}
+  \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdffeedback creationdate}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \subsubsection{Trimming leading and trailing spaces}
 % \label{sec:trim-spaces}
 %
@@ -2380,145 +2796,6 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\hyxmp at pdf@to at xmp@date}
-% Convert a timestamp from \acro{PDF}'s
-% |D:|\textsc{yyyymmdd}hhmmss|-|\textsc{tt}|'|tt|'| format
-% \makeatletter
-% \@ifundefined{pdffeedback}{^^A
-%   \@ifundefined{pdfcreationdate}{^^A
-%   }{^^A
-%     (e.g.,~\texttt{\pdfcreationdate})
-%   }^^A
-% }{^^A
-%   (e.g.,~\texttt{\pdffeedback creationdate})
-% }
-% \makeatother
-% to \acro{XMP}'s
-% \textsc{yyyy}|-|\textsc{mm}|-|\textsc{dd}|T|hh|:|mm|:|ss|+|\textsc{tt}|:|tt format
-% \makeatletter
-% \@ifundefined{pdffeedback}{^^A
-%   \@ifundefined{pdfcreationdate}{^^A
-%     \unskip
-%   }{^^A
-%     (e.g.,~\texttt{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate})^^A
-%   }^^A
-% }{^^A
-%   (e.g.,~\texttt{\expandafter\hyxmp at pdf@to at xmp@date\pdffeedback creationdate})^^A
-% }^^A
-% \makeatother
-% ~\cite{Adobe2012:XMP}.  This macro is fully expandable.^^A
-% \changes{v2.4}{2013/12/24}{Added this macro}
-%    \begin{macrocode}
-\def\hyxmp at pdf@to at xmp@date#1:#2#3#4#5#6#7#8#9{%
-  #2#3#4#5-#6#7-#8#9%
-  \hyxmp at parse@time
-}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\hyxmp at parse@time}
-% This is a helper function for |\hyxmp at pdf@to at xmp@date|.
-% |\hyxmp at pdf@to at xmp@date| proper parses only the year, month, and day
-% then calls |\hyxmp at parse@time|.  |\hyxmp at parse@time| parses the
-% hours, minutes, and seconds then calls |\hyxmp at parse@tz at char|.
-% \changes{v2.4}{2013/12/24}{Added this macro}
-%    \begin{macrocode}
-\def\hyxmp at parse@time#1#2#3#4#5#6{%
-  T#1#2:#3#4:#5#6%
-  \hyxmp at parse@tz at char
-}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\hyxmp at parse@tz at char}
-% This is another helper function for |\hyxmp at pdf@to at xmp@date|.  So far,
-% the date and time have been parsed.  |\hyxmp at parse@tz at char| parses the
-% first character of the timezone descriptor.  This can be one of
-% ``|+|'' for eastern timezones (\mbox{UTC$+x$}, including Asia,
-% Oceania, and most of Europe), ``|-|'' for western timezones
-% (\mbox{UTC$-x$}, primarily the Americas), or ``|Z|'' for Zulu time
-% (\mbox{UTC$+0$}).  Timezones beginning with ``|+|'' or ``|-|'' are
-% followed by an offset in hours and minutes (parsed by
-% |\hyxmp at parse@tz|; timezones beginning with ``|Z|'' are not.
-% \changes{v2.4}{2013/12/24}{Added this macro}
-%    \begin{macrocode}
-\def\hyxmp at parse@tz at char#1{%
-  #1%
-  \ifx#1-%
-    \expandafter\hyxmp at parse@tz
-  \else
-    \ifx#1+%
-      \expandafter\hyxmp at parse@tz
-    \fi
-  \fi
-}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\hyxmp at parse@tz}
-% This is the final helper function for |\hyxmp at pdf@to at xmp@date|.  It
-% parses the piece of the timezone comprising the offset from
-% Coordinated Universal Time, measured in hours and minutes.
-% \changes{v2.4}{2013/12/24}{Added this macro}
-%    \begin{macrocode}
-\def\hyxmp at parse@tz#1'#2'{%
-  #1:#2%
-}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\hyxmp at today@define}
-% Use \TeX's |\year|, |\month|, and |\day| primitives to define a given
-% macro as today's date in \textsc{yyyy}-\textsc{mm}-\textsc{dd} format.
-% \changes{v2.4}{2013/12/21}{Added this macro}
-% \changes{v3.0}{2016/07/03}{Modified to accept the name of a macro
-%   to define}
-%    \begin{macrocode}
-\def\hyxmp at today@define#1{%
-  \xdef#1{\the\year}%
-  \ifnum\month<10
-    \xdef#1{#1-0\the\month}%
-  \else
-    \xdef#1{#1-\the\month}%
-  \fi
-  \ifnum\day<10
-    \xdef#1{#1-0\the\day}%
-  \else
-    \xdef#1{#1-\the\day}%
-  \fi
-}
-%    \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\hyxmp at today}
-% Define |\hyxmp at today| as the current date and (if available) time and
-% timezone in \acro{XMP} \xmpterm{Date} format~\cite{Adobe2012:XMP}.
-% \changes{v2.4}{2013/12/24}{Modified the code to parse the time and
-%   timezone from \texttt{\string\string\string\pdfcreationdate}, as
-%   proposed by Florian Breitwieser}
-%    \begin{macrocode}
-\@ifundefined{pdffeedback}{%
-  \@ifundefined{pdfcreationdate}{%
-%    \end{macrocode}
-% Case 1: Neither |\pdffeedback| nor |\pdfcreationdate| is defined
-% (\XeLaTeX\ and regular \LaTeX).
-%    \begin{macrocode}
-    \hyxmp at today@define\hyxmp at today
-  }{%
-%    \end{macrocode}
-% Case 2: |\pdfcreationdate| is defined (\pdfLaTeX\ and pre-0.85 \LuaLaTeX).
-%    \begin{macrocode}
-    \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate}%
-  }%
-}{%
-%    \end{macrocode}
-% Case 3: |\pdffeedback| is defined (\LuaLaTeX~0.85+).
-%    \begin{macrocode}
-  \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdffeedback creationdate}%
-}
-%    \end{macrocode}
-% \end{macro}
-%
 % \begin{macro}{\hyxmp at x@default}
 % Define an |x-default| string that we can use in comparisons with
 % |\@pdfmetalang|.
@@ -2926,6 +3203,11 @@
 %   \protect\xmpterm{CreateDate}, \protect\xmpterm{ModifyDate}, and
 %   \protect\xmpterm{MetadataDate} match the \protect\acro{PDF}
 %   \protect\pdfterm{CreationDate}}
+% \changes{v3.2}{2017/01/22}{Honor \string\pkgname{hyperref}'s
+%   \string\optname{pdfcreationdate} and \string\optname{pdfmoddate}
+%   options plus a new \string\optname{pdfmetadate} option.  Leonid
+%   Sinev requested this additional control and helped test the resulting
+%   \protect\pkgname{hyperxmp} code}
 %    \begin{macrocode}
 \newcommand*{\hyxmp at xmp@basic at schema}{%
   \hyxmp at add@to at xml{%
@@ -2933,9 +3215,49 @@
 ____________xmlns:xmp="http://ns.adobe.com/xap/1.0/">^^J%
   }%
   \hyxmp at define@createdate
-  \hyxmp at add@simple{xmp:CreateDate}{\hyxmp at createdate}%
-  \hyxmp at add@simple{xmp:ModifyDate}{\hyxmp at createdate}%
-  \hyxmp at add@simple{xmp:MetadataDate}{\hyxmp at createdate}%
+%    \end{macrocode}
+% For the document's creation date, use the user-specified
+% |\@pdfcreationdate| if defined and non-empty.  Otherwise use our
+% fabricated |\hyxmp at createdate|.
+%    \begin{macrocode}
+  \@ifundefined{@pdfcreationdate}{%
+    \hyxmp at add@simple{xmp:CreateDate}{\hyxmp at createdate}%
+  }{%
+    \ifx\@pdfcreationdate\@empty
+      \hyxmp at add@simple{xmp:CreateDate}{\hyxmp at createdate}%
+    \else
+      \hyxmp at add@simple{xmp:CreateDate}{%
+        \expandafter\hyxmp at as@xmp at date\expandafter{\@pdfcreationdate}}%
+    \fi
+  }%
+%    \end{macrocode}
+% For the document's modification date, use the user-specified
+% |\@pdfmoddate| if defined and non-empty.  Otherwise use our
+% fabricated |\hyxmp at createdate|.
+%    \begin{macrocode}
+  \@ifundefined{@pdfmoddate}{%
+    \hyxmp at add@simple{xmp:ModifyDate}{\hyxmp at createdate}%
+  }{%
+    \ifx\@pdfmoddate\@empty
+      \hyxmp at add@simple{xmp:ModifyDate}{\hyxmp at createdate}%
+    \else
+      \hyxmp at add@simple{xmp:ModifyDate}{%
+        \expandafter\hyxmp at as@xmp at date\expandafter{\@pdfmoddate}}%
+    \fi
+  }%
+%    \end{macrocode}
+% For the document's metadata date, use the user-specified
+% |\@pdfmetadatetime| if defined and non-empty.  Otherwise use our
+% fabricated |\hyxmp at createdate|.
+%    \begin{macrocode}
+  \ifx\@pdfmetadatetime\@empty
+    \hyxmp at add@simple{xmp:MetadataDate}{\hyxmp at createdate}%
+  \else
+    \hyxmp at add@simple{xmp:MetadataDate}{\@pdfmetadatetime}%
+  \fi
+%    \end{macrocode}
+% Define the creation tool and the base \acro{URL}.
+%    \begin{macrocode}
   \hyxmp at add@simple{xmp:CreatorTool}{\@pdfcreator}%
   \hyxmp at add@simple{xmp:BaseURL}{\@baseurl}%
   \hyxmp at add@to at xml{%
@@ -3358,14 +3680,44 @@
 %
 % \subsubsection{Embedding using \pdfTeX}
 %
+% Up to version~0.85, \LuaTeX\ supported the \pdfTeX\ primitives, and
+% \pkgname{hyperref} didn't distinguish the two backends.  However, from
+% \pkgname{hyperxmp}'s perspective there is one key difference: the
+% effect of |\pdfcompresslevel| is local to a group in \pdfTeX\ but is
+% global in \LuaTeX\@.
+%
+% The \acro{PDF} object representing the \acro{XMP} packet is supposed
+% to include an uncompressed stream so it can be read by
+% non-\acro{PDF}-aware tools.  However, we don't want to unnecessarily
+% uncompress \emph{every} \acro{PDF} stream.  The solution, provided by
+% Hans Hagen on the |luatex| mailing list (thread:
+% \href{http://tug.org/pipermail/luatex/2016-July/006077.html}{``Leaving
+%   a single PDF object uncompressed''}, 6\,\textsc{Jul}\,2016), is to
+% provide the |uncompressed| flag to |\pdfobj|.  Our definition of
+% |\hyxmp at embed@packet at pdftex| uses the \pkgname{ifluatex} package to
+% distinguish the \pdfTeX\ case from the pre-0.85 \LuaTeX\ case.
+%
+%    \begin{macrocode}
+\RequirePackage{ifluatex}
+%    \end{macrocode}
+%
 % \begin{macro}{\hyxmp at embed@packet at pdftex}
 % Embed the \acro{XMP} packet using \pdfTeX\ primitives, which are
-% supported by both \pdfTeX\ and pre-0.85 \LuaTeX.
+% supported by both \pdfTeX\ and pre-0.85 \LuaTeX.  The only difference
+% is that in the former case we locally specify |\pdfcompresslevel=0| to
+% leave the \acro{PDF} object uncompressed while in the latter case we
+% pass the |uncompressed| flag to |\pdfobj| to achieve the same effect.
+% \changes{v3.1}{2016/07/06}{Leave the \protect\acro{XMP} packet---and
+%   only the \protect\acro{XMP} packet---uncompressed in both
+%   \protect\pdfTeX\ and pre-0.85 \protect\LuaTeX}
 %    \begin{macrocode}
 \newcommand*{\hyxmp at embed@packet at pdftex}{%
   \bgroup
-    \pdfcompresslevel=0
-    \immediate\pdfobj stream attr {%
+    \ifluatex
+    \else
+      \pdfcompresslevel=0
+    \fi
+    \immediate\pdfobj \ifluatex uncompressed\fi stream attr {%
       /Type /Metadata
       /Subtype /XML
     }{\hyxmp at xml}%
@@ -3377,45 +3729,18 @@
 %
 % \subsubsection{Embedding using \LuaTeX~0.85+}
 %
-% If we're running \LuaLaTeX~0.85+ we apparently need to use \Lua\
-% directly to leave uncompressed the \acro{PDF} object holding the
-% \acro{XMP} packet.  The \pkgname{luacode} package facilitates the
-% inclusion of Lua code in a \LaTeX\ document.
-%    \begin{macrocode}
-\expandafter\ifx\csname pdffeedback\endcsname\relax
-\else
-  \RequirePackage{luacode}%
-%    \end{macrocode}
-%
-% \begin{luafunc}{hyxmp_embed_packet}
-% We define a \Lua\ function, |hyxmp_embed_packet|, that embeds a string
-% as an uncompressed \acro{PDF} object of tyoe \xmpterm{Metadata}.
-% \changes{v3.0}{2016/07/02}{Added this \protect\Lua\ function}
-%    \begin{macrocode}
-  \begin{luacode*}
-  function hyxmp_embed_packet (contents)
-      local n = pdf.obj {
-          type = "stream",
-          attr = [[
-/Type /Metadata
-/Subtype /XML
-          ]],
-          compresslevel = 0,
-          string = contents
-      }
-      pdf.refobj(n)
-  end
-  \end{luacode*}
-\fi
-%    \end{macrocode}
-% \end{luafunc}
-%
 % \begin{macro}{\hyxmp at embed@packet at luatex}
 % Embed the \acro{XMP} packet using \LuaTeX~0.85+ primitives.
 % \changes{v3.0}{2016/07/02}{Added this macro}
+% \changes{v3.1}{2016/07/06}{Updated to use
+%   \protect\texttt{\string\string\string\pdfextension\ obj uncompressed}
+%   as suggested by Hans Hagen}
 %    \begin{macrocode}
 \newcommand*{\hyxmp at embed@packet at luatex}{%
-  \luadirect{hyxmp_embed_packet(\luastring{\hyxmp at xml})}%
+  \immediate\pdfextension obj uncompressed stream attr {%
+    /Type /Metadata
+    /Subtype /XML
+  }{\hyxmp at xml}%
   \pdfextension catalog {/Metadata \the\numexpr\pdffeedback lastobj\relax\space 0 R}%
 }
 %    \end{macrocode}
@@ -3429,7 +3754,7 @@
 % \optname{dvipsone}, \optname{dvips}, \optname{dviwindo},
 % \optname{nativepdf}, \optname{pdfmark}, \optname{ps2pdf},
 % \optname{textures}, and \optname{vtexpdfmark} options to
-% \pkgname{hyperref} but I've tested only a few of those.
+% \pkgname{hyperref}, but I've tested only a few of those.
 %    \begin{macrocode}
 \newcommand*{\hyxmp at embed@packet at pdfmark}{%
   \pdfmark{%

Modified: trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.ins	2017-02-23 21:59:58 UTC (rev 43315)
+++ trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.ins	2017-02-23 22:00:11 UTC (rev 43316)
@@ -1,5 +1,5 @@
 %%
-%% Copyright (C) 2016 by Scott Pakin <scott+hyxmp at pakin.org>
+%% Copyright (C) 2017 by Scott Pakin <scott+hyxmp at pakin.org>
 %%
 %% This file may be distributed and/or modified under the conditions of
 %% the LaTeX Project Public License, either version 1.3c of this license
@@ -21,7 +21,7 @@
 
 This is a generated file.
 
-Copyright (C) 2016 by Scott Pakin <scott+hyxmp at pakin.org>
+Copyright (C) 2017 by Scott Pakin <scott+hyxmp at pakin.org>
 
 This file may be distributed and/or modified under the conditions of
 the LaTeX Project Public License, either version 1.3c of this license

Modified: trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty	2017-02-23 21:59:58 UTC (rev 43315)
+++ trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty	2017-02-23 22:00:11 UTC (rev 43316)
@@ -8,7 +8,7 @@
 %% 
 %% This is a generated file.
 %% 
-%% Copyright (C) 2016 by Scott Pakin <scott+hyxmp at pakin.org>
+%% Copyright (C) 2017 by Scott Pakin <scott+hyxmp at pakin.org>
 %% 
 %% This file may be distributed and/or modified under the conditions of
 %% the LaTeX Project Public License, either version 1.3c of this license
@@ -22,8 +22,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{hyperxmp}
-    [2016/07/04 v3.0 Store hyperref metadata in XMP format]
-
+    [2017/02/23 v3.2 Store hyperref metadata in XMP format]
 \edef\hyxmp at dq@code{\the\catcode`\"}
 \catcode`\"=12
 \def\hyxmp at driver{hpdftex}
@@ -45,7 +44,27 @@
   \let\textunderscore=\hyxmp at textunderscore
 }
 \def\@pdfdatetime{}
-\define at key{Hyp}{pdfdate}{\hyxmp at pdfstringdef\@pdfdatetime{#1}}
+\define at key{Hyp}{pdfdate}{%
+  \begingroup
+    \Hy at unicodefalse
+    \edef\next{%
+      \noexpand\hyxmp at pdfstringdef\noexpand\@pdfdatetime{%
+        \noexpand\hyxmp at as@xmp at date{#1}}%
+    }%
+    \next
+  \endgroup
+}
+\def\@pdfmetadatetime{}
+\define at key{Hyp}{pdfmetadate}{%
+  \begingroup
+    \Hy at unicodefalse
+    \edef\next{%
+      \noexpand\hyxmp at pdfstringdef\noexpand\@pdfmetadatetime{%
+        \noexpand\hyxmp at as@xmp at date{#1}}%
+    }%
+    \next
+  \endgroup
+}
 \def\@pdfcopyright{}
 \define at key{Hyp}{pdfcopyright}{\hyxmp at pdfstringdef\@pdfcopyright{#1}}
 \def\@pdftype{Text}
@@ -151,13 +170,16 @@
     \@pdfcontactregion
     \@pdfcontacturl
     \@pdfcopyright
-    \@pdftype
+    \@pdfcreationdate
     \@pdfdatetime
     \@pdfkeywords
     \@pdflang
     \@pdflicenseurl
+    \@pdfmetadatetime
+    \@pdfmoddate
     \@pdfsubject
     \@pdftitle
+    \@pdftype
   }%
   \ifx\hyxmp at concated@metadata\@empty
     \PackageWarningNoLine{hyperxmp}{%
@@ -245,6 +267,138 @@
   }
   \hyxmp at temp@list
 }}
+\def\hyxmp at first@char#1{\hyxmp at first@char at i#1\relax}
+\def\hyxmp at first@char at i#1#2\relax{#1}
+\def\hyxmp at as@xmp at date#1{%
+  \expandafter\ifx\hyxmp at first@char at i#1\relax D%
+    \hyxmp at pdf@to at xmp@date{#1}%
+  \else
+    #1%
+  \fi
+}
+\def\hyxmp at pdf@to at xmp@date#1:#2#3#4#5#6#7#8#9{%
+  #2#3#4#5-#6#7-#8#9%
+  \hyxmp at parse@time
+}
+\def\hyxmp at parse@time#1#2#3#4#5#6{%
+  T#1#2:#3#4:#5#6%
+  \hyxmp at parse@tz at char
+}
+\def\hyxmp at parse@tz at char#1{%
+  #1%
+  \ifx#1-%
+    \expandafter\hyxmp at parse@tz
+  \else
+    \ifx#1+%
+      \expandafter\hyxmp at parse@tz
+    \fi
+  \fi
+}
+\def\hyxmp at parse@tz#1'#2'{%
+  #1:#2%
+}
+\def\hyxmp at as@pdf at date#1{%
+  \expandafter\ifx\hyxmp at first@char at i#1\relax D%
+    #1%
+  \else
+    \hyxmp at xmp@to at pdf@date{#1}%
+  \fi
+}
+\def\hyxmp at xmp@to at pdf@date#1{%
+  D:\hyxmp at xmp@to at pdf@date at i#1\relax\relax
+}
+\def\hyxmp at xmp@to at pdf@date at i#1#2#3#4#5#6{%
+  #1#2#3#4%
+  \ifx#5-%
+    \expandafter\hyxmp at xmp@to at pdf@date at ii\expandafter#6%
+  \fi
+}
+\def\hyxmp at xmp@to at pdf@date at ii#1#2#3#4{%
+  #1#2%
+  \ifx#3-%
+    \expandafter\hyxmp at xmp@to at pdf@date at iii\expandafter#4%
+  \fi
+}
+\def\hyxmp at xmp@to at pdf@date at iii#1#2#3#4{%
+  #1#2%
+  \ifx#3T%
+    \expandafter\hyxmp at xmp@to at pdf@date at iv\expandafter#4%
+  \fi
+}
+\def\hyxmp at xmp@to at pdf@date at iv#1#2#3#4{%
+  #1#2%
+  \ifx#3:%
+    \expandafter\hyxmp at xmp@to at pdf@date at v\expandafter#4%
+  \fi
+}
+\def\hyxmp at xmp@to at pdf@date at v#1#2#3#4{%
+  #1#2%
+  \ifx#3:%
+    \expandafter\hyxmp at xmp@to at pdf@date at vi\expandafter#4%
+  \fi
+}
+\let\@hyxmp at gobbletwo=\@gobbletwo
+\def\hyxmp at xmp@to at pdf@date at vi#1#2#3#4{%
+  #1#2%
+  \ifx#3+%
+    +\expandafter\hyxmp at xmp@to at pdf@date at vii
+  \fi
+  \ifx#3-%
+    -\expandafter\hyxmp at xmp@to at pdf@date at vii
+  \fi
+  \ifx#3Z%
+    Z%
+  \fi
+  \ifx#3\relax
+    \expandafter\@hyxmp at gobbletwo
+  \fi
+  \@gobbletwo #4%
+}
+\def\hyxmp at xmp@to at pdf@date at vii#1\@gobbletwo#2#3#4#5{%
+  #2#3%
+  \ifx#4:%
+    \expandafter\hyxmp at xmp@to at pdf@date at viii\expandafter#5%
+  \fi
+}
+\def\hyxmp at xmp@to at pdf@date at viii#1#2#3#4{%
+  '#1#2'%
+}
+\def\hyxmp at today@define#1{%
+  \xdef#1{\the\year}%
+  \ifnum\month<10
+    \xdef#1{#1-0\the\month}%
+  \else
+    \xdef#1{#1-\the\month}%
+  \fi
+  \ifnum\day<10
+    \xdef#1{#1-0\the\day}%
+  \else
+    \xdef#1{#1-\the\day}%
+  \fi
+  \@tempcnta=\time
+  \divide\@tempcnta by 60%
+  \ifnum\@tempcnta<10%
+    \xdef#1{#1T0\the\@tempcnta}%
+  \else
+    \xdef#1{#1T\the\@tempcnta}%
+  \fi
+  \multiply\@tempcnta by -60%
+  \advance\@tempcnta by \time
+  \ifnum\@tempcnta<10%
+    \xdef#1{#1:0\the\@tempcnta}%
+  \else
+    \xdef#1{#1:\the\@tempcnta}%
+  \fi
+}
+\@ifundefined{pdffeedback}{%
+  \@ifundefined{pdfcreationdate}{%
+    \hyxmp at today@define\hyxmp at today
+  }{%
+    \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate}%
+  }%
+}{%
+  \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdffeedback creationdate}%
+}
 \catcode`\Q=3
 \newcommand{\hyxmp at trimspaces}[1]{%
   \begingroup
@@ -585,49 +739,6 @@
 \xdef\hyxmp at padding{\hyxmp at padding\hyxmp at padding}
 \xdef\hyxmp at padding{\hyxmp at padding\hyxmp at padding}
 \xdef\hyxmp at padding{\hyxmp at padding\hyxmp at padding}
-\def\hyxmp at pdf@to at xmp@date#1:#2#3#4#5#6#7#8#9{%
-  #2#3#4#5-#6#7-#8#9%
-  \hyxmp at parse@time
-}
-\def\hyxmp at parse@time#1#2#3#4#5#6{%
-  T#1#2:#3#4:#5#6%
-  \hyxmp at parse@tz at char
-}
-\def\hyxmp at parse@tz at char#1{%
-  #1%
-  \ifx#1-%
-    \expandafter\hyxmp at parse@tz
-  \else
-    \ifx#1+%
-      \expandafter\hyxmp at parse@tz
-    \fi
-  \fi
-}
-\def\hyxmp at parse@tz#1'#2'{%
-  #1:#2%
-}
-\def\hyxmp at today@define#1{%
-  \xdef#1{\the\year}%
-  \ifnum\month<10
-    \xdef#1{#1-0\the\month}%
-  \else
-    \xdef#1{#1-\the\month}%
-  \fi
-  \ifnum\day<10
-    \xdef#1{#1-0\the\day}%
-  \else
-    \xdef#1{#1-\the\day}%
-  \fi
-}
-\@ifundefined{pdffeedback}{%
-  \@ifundefined{pdfcreationdate}{%
-    \hyxmp at today@define\hyxmp at today
-  }{%
-    \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate}%
-  }%
-}{%
-  \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdffeedback creationdate}%
-}
 \newcommand*{\hyxmp at x@default}{x-default}
 \newcommand*{\hyxmp at pdf@schema}{%
   \hyxmp at add@to at xml{%
@@ -800,9 +911,31 @@
 ____________xmlns:xmp="http://ns.adobe.com/xap/1.0/">^^J%
   }%
   \hyxmp at define@createdate
-  \hyxmp at add@simple{xmp:CreateDate}{\hyxmp at createdate}%
-  \hyxmp at add@simple{xmp:ModifyDate}{\hyxmp at createdate}%
-  \hyxmp at add@simple{xmp:MetadataDate}{\hyxmp at createdate}%
+  \@ifundefined{@pdfcreationdate}{%
+    \hyxmp at add@simple{xmp:CreateDate}{\hyxmp at createdate}%
+  }{%
+    \ifx\@pdfcreationdate\@empty
+      \hyxmp at add@simple{xmp:CreateDate}{\hyxmp at createdate}%
+    \else
+      \hyxmp at add@simple{xmp:CreateDate}{%
+        \expandafter\hyxmp at as@xmp at date\expandafter{\@pdfcreationdate}}%
+    \fi
+  }%
+  \@ifundefined{@pdfmoddate}{%
+    \hyxmp at add@simple{xmp:ModifyDate}{\hyxmp at createdate}%
+  }{%
+    \ifx\@pdfmoddate\@empty
+      \hyxmp at add@simple{xmp:ModifyDate}{\hyxmp at createdate}%
+    \else
+      \hyxmp at add@simple{xmp:ModifyDate}{%
+        \expandafter\hyxmp at as@xmp at date\expandafter{\@pdfmoddate}}%
+    \fi
+  }%
+  \ifx\@pdfmetadatetime\@empty
+    \hyxmp at add@simple{xmp:MetadataDate}{\hyxmp at createdate}%
+  \else
+    \hyxmp at add@simple{xmp:MetadataDate}{\@pdfmetadatetime}%
+  \fi
   \hyxmp at add@simple{xmp:CreatorTool}{\@pdfcreator}%
   \hyxmp at add@simple{xmp:BaseURL}{\@baseurl}%
   \hyxmp at add@to at xml{%
@@ -1036,10 +1169,14 @@
     \fi
   \fi
 }
+\RequirePackage{ifluatex}
 \newcommand*{\hyxmp at embed@packet at pdftex}{%
   \bgroup
-    \pdfcompresslevel=0
-    \immediate\pdfobj stream attr {%
+    \ifluatex
+    \else
+      \pdfcompresslevel=0
+    \fi
+    \immediate\pdfobj \ifluatex uncompressed\fi stream attr {%
       /Type /Metadata
       /Subtype /XML
     }{\hyxmp at xml}%
@@ -1046,26 +1183,11 @@
     \pdfcatalog {/Metadata \the\pdflastobj\space 0 R}%
   \egroup
 }
-\expandafter\ifx\csname pdffeedback\endcsname\relax
-\else
-  \RequirePackage{luacode}%
-  \begin{luacode*}
-  function hyxmp_embed_packet (contents)
-      local n = pdf.obj {
-          type = "stream",
-          attr = [[
-/Type /Metadata
-/Subtype /XML
-          ]],
-          compresslevel = 0,
-          string = contents
-      }
-      pdf.refobj(n)
-  end
-  \end{luacode*}
-\fi
 \newcommand*{\hyxmp at embed@packet at luatex}{%
-  \luadirect{hyxmp_embed_packet(\luastring{\hyxmp at xml})}%
+  \immediate\pdfextension obj uncompressed stream attr {%
+    /Type /Metadata
+    /Subtype /XML
+  }{\hyxmp at xml}%
   \pdfextension catalog {/Metadata \the\numexpr\pdffeedback lastobj\relax\space 0 R}%
 }
 \newcommand*{\hyxmp at embed@packet at pdfmark}{%



More information about the tex-live-commits mailing list