texlive[41626] Master/texmf-dist: hyperxmp (4jul16)

commits+karl at tug.org commits+karl at tug.org
Mon Jul 4 23:57:47 CEST 2016


Revision: 41626
          http://tug.org/svn/texlive?view=revision&revision=41626
Author:   karl
Date:     2016-07-04 23:57:47 +0200 (Mon, 04 Jul 2016)
Log Message:
-----------
hyperxmp (4jul16)

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

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	2016-07-04 21:57:35 UTC (rev 41625)
+++ trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx	2016-07-04 21:57:47 UTC (rev 41626)
@@ -22,7 +22,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{hyperxmp}
 %<*package>
-    [2016/04/27 v2.9 Store hyperref metadata in XMP format]
+    [2016/07/04 v3.0 Store hyperref metadata in XMP format]
 %</package>
 %
 %<*driver>
@@ -81,7 +81,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{1551}
+% \CheckSum{1593}
 %
 % \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
@@ -123,18 +123,22 @@
 % \changes{v2.9}{2016/04/26}{Introduced the \protect\optname{pdftype}
 %   package option, which enables an author to specify the type of
 %   document being produced}
+% \changes{v3.0}{2016/07/02}{Made the code compatible with \string\LuaTeX~0.85.
+%   Thanks to Robert Schlicht, Leonid Sinev, and David Carlisle for bug
+%   reports and to Leonid Sinev for helping test the new
+%   \protect\pkgname{hyperxmp} code}
 %
 % \GetFileInfo{hyperxmp.dtx}
 %
-% \DoNotIndex{\!,\",\#,\^,\(,\),\*,\,,\<,\>,\\,\^,\_,\~,\ }
-% \DoNotIndex{\@cons,\@empty,\@ifpackageloaded,\@ifundefined,\@nil}
-% \DoNotIndex{\@tempcnta,\@tempcntb,\MessageBreak,\advance,\afterassignment}
-% \DoNotIndex{\aftergroup,\begingroup,\bgroup,\catcode,\csname,\def,\divide}
-% \DoNotIndex{\edef,\egroup,\else,\endcsname,\endgroup,\expandafter,\fi}
-% \DoNotIndex{\futurelet,\g at addto@macro,\gdef,\global,\if,\ifcase,\ifnum}
-% \DoNotIndex{\ifx,\immediate,\lccode,\let,\loop,\lowercase,\multiply}
-% \DoNotIndex{\newcommand,\noexpand,\or,\relax,\repeat,\space,\string,\the}
-% \DoNotIndex{\toks,\uccode,\uppercase,\usepackage,\xdef}
+% \DoNotIndex{,\,\ ,\!,\",\#,\(,\),\*,\<,\>,\@cons,\@empty}
+% \DoNotIndex{\@ifpackageloaded,\@ifundefined,\@nil,\@tempcnta,\@tempcntb}
+% \DoNotIndex{\MessageBreak,\\,\^,\^,\_,\advance,\afterassignment}
+% \DoNotIndex{\aftergroup,\begin,\begingroup,\bgroup,\catcode,\csname,\def}
+% \DoNotIndex{\divide,\edef,\egroup,\else,\end,\endcsname,\endgroup}
+% \DoNotIndex{\expandafter,\fi,\futurelet,\g at addto@macro,\gdef,\global,\if}
+% \DoNotIndex{\ifcase,\ifnum,\ifx,\immediate,\lccode,\let,\loop,\lowercase}
+% \DoNotIndex{\multiply,\newcommand,\noexpand,\or,\relax,\repeat,\space}
+% \DoNotIndex{\string,\the,\toks,\uccode,\uppercase,\usepackage,\xdef,\~}
 %
 % ^^A  Define a few logical styles.
 % \DeclareRobustCommand{\term}[1]{#1\SortIndex{#1}{#1}}
@@ -199,7 +203,29 @@
 % \DeclareRobustCommand{\Dvips}{^^A
 %   \texorpdfstring{Dvips\SortIndex{dvips}{\texttt{dvips}}}{Dvips}^^A
 % }
+% \DeclareRobustCommand{\Lua}{^^A
+%   Lua\index{Lua}^^A
+% }
 %
+% ^^A  Define an environment just like macro but for Lua functions.
+% \makeatletter
+% \newenvironment{luafunc}{^^A
+%   \begingroup
+%     \catcode`\_=11
+%     \def\PrintMacroName##1{\strut\MacroFont\string##1\ }^^A
+%     \def\SpecialIndex@##1##2{^^A
+%       \@bsphack
+%       \special at index{\string##1\actualchar
+%         \string\verb\quotechar*\verbatimchar##1\verbatimchar##2}^^A
+%       \@esphack
+%     }^^A
+%     \begin{macro}^^A
+% }{^^A
+%     \end{macro}^^A
+%   \endgroup
+% }
+% \makeatother
+%
 % ^^A  Pack figures a bit tighter onto the page.
 % \renewcommand{\floatpagefraction}{0.8}
 %
@@ -600,20 +626,40 @@
 % \end{verbatim}
 %
 %
-% \paragraph{Note~3: \XeLaTeX\ object compression}
-% \XeLaTeX\ (or, more precisely, the \cmdname{xdvipdfmx} back end),
-% compresses \emph{all} \acro{PDF} objects, including the ones
-% containing \acro{XMP} metadata.  While Adobe Acrobat can still detect
-% and utilize the \acro{XMP} metadata, non-\acro{PDF}-aware applications
-% are unlikely to see the metadata.  Three options to consider are to
-% (1)~use a different program (e.g.,~\LuaLaTeX), (2)~pass the
-% |--output-driver="xdvipdfmx -z0"| option to \XeLaTeX\ to instruct
-% \cmdname{xdvipdfmx} to turn off all compression (which will of course
-% make the \acro{PDF} file substantially larger), or (3)~postprocess the
-% generated \acro{PDF} file by loading it into the commercial version of
-% Adobe Acrobat and re-saving it with the Save As\dots\ menu option.
+% \paragraph{Note~3: Object compression}
+% One intention of \acro{XMP} is that metadata embedded in a file be
+% readable even without knowledge of the file's format.  That is, the
+% metadata are expected to appear as plain text.  Although
+% \pkgname{hyperxmp} does its best to honor that intention, it faces
+% a few challenges:
 %
+% \begin{enumerate}
+% \item When run with versions of \LuaLaTeX\ earlier than 0.85,
+%   \pkgname{hyperxmp} leaves all \acro{PDF} objects uncompressed.  This
+%   is due to \LuaLaTeX\ treating object compression as a global
+%   parameter, unlike \pdfLaTeX, which treats it as a local parameter.
+%   Hence, when \pkgname{hyperxmp} requests that the \acro{XMP} packet
+%   be left uncompressed, \LuaLaTeX\ in fact leaves \emph{all}
+%   \acro{PDF} streams uncompressed.  Beginning with version~3.0,
+%   \pkgname{hyperxmp} includes a workaround that correctly leaves only
+%   the \acro{XMP} metadata uncompressed, but this workaround is
+%   implemented only for \LuaLaTeX\ v0.85 onwards.
 %
+% \item \XeLaTeX\ (or, more precisely, the \cmdname{xdvipdfmx} back end)
+%   exhibits the opposite problem.  It compresses \emph{all} \acro{PDF}
+%   objects, including the ones containing \acro{XMP} metadata.  While
+%   Adobe Acrobat can still detect and utilize the \acro{XMP} metadata,
+%   non-\acro{PDF}-aware applications are unlikely to see the metadata.
+%   Three options to consider are to (1)~use a different program
+%   (e.g.,~\LuaLaTeX), (2)~pass the |--output-driver="xdvipdfmx -z0"|
+%   option to \XeLaTeX\ to instruct \cmdname{xdvipdfmx} to turn off all
+%   compression (which will of course make the \acro{PDF} file
+%   substantially larger), or (3)~postprocess the generated \acro{PDF}
+%   file by loading it into the commercial version of Adobe Acrobat and
+%   re-saving it with the Save As\dots\ menu option.
+% \end{enumerate}
+%
+%
 % \paragraph{Note~4: Literal commas}
 % \pkgname{hyperxmp} splits the \optname{pdfauthor} and
 % \optname{pdfkeywords} lists at commas.  Therefore, when specifying
@@ -723,7 +769,6 @@
 %
 % \input{einstein-xmp}
 %
-%
 % \begin{thebibliography}{1}
 % \bibitem{Adobe2010:pdfmark}
 % Adobe Systems, Inc., San Jose, California.
@@ -2316,13 +2361,13 @@
 % The \acro{XMP} specification recommends leaving approximately
 % 2000~bytes of whitespace at the end of each \acro{XMP} packet to
 % facilitate editing the packet in place~\cite{Adobe2012:XMP}.
-% |\hyxmp at padding| is defined to contain 32~lines of 50~spaces and a
-% newline apiece for a total of 1632 characters of whitespace.
+% |\hyxmp at padding| is defined to contain 32~lines of 63~spaces and a
+% newline apiece for a total of 2048 characters of whitespace.
 %    \begin{macrocode}
 \bgroup
   \xdef\hyxmp at xml{}%
   \hyxmp at add@to at xml{%
-__________________________________________________^^J%
+_______________________________________________________________^^J%
   }
   \xdef\hyxmp at padding{\hyxmp at xml}%
 \egroup
@@ -2338,18 +2383,28 @@
 % \begin{macro}{\hyxmp at pdf@to at xmp@date}
 % Convert a timestamp from \acro{PDF}'s
 % |D:|\textsc{yyyymmdd}hhmmss|-|\textsc{tt}|'|tt|'| format
-% \expandafter\ifx\csname pdfcreationdate\endcsname\relax
-% \else
-%   (e.g.,~\texttt{\pdfcreationdate})
-% \fi
+% \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
-% \expandafter\ifx\csname pdfcreationdate\endcsname\relax
-%   \unskip
-% \else
-%   (e.g.,~\texttt{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate})^^A
-% \fi
+% \@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}
@@ -2413,22 +2468,23 @@
 % \end{macro}
 %
 % \begin{macro}{\hyxmp at today@define}
-% Use \TeX's |\year|, |\month|, and |\day| primitives to define
-% |\hyxmp at today| as today's date in
-% \textsc{yyyy}-\textsc{mm}-\textsc{dd} format.
+% 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{%
-  \xdef\hyxmp at today{\the\year}%
+\def\hyxmp at today@define#1{%
+  \xdef#1{\the\year}%
   \ifnum\month<10
-    \xdef\hyxmp at today{\hyxmp at today-0\the\month}%
+    \xdef#1{#1-0\the\month}%
   \else
-    \xdef\hyxmp at today{\hyxmp at today-\the\month}%
+    \xdef#1{#1-\the\month}%
   \fi
   \ifnum\day<10
-    \xdef\hyxmp at today{\hyxmp at today-0\the\day}%
+    \xdef#1{#1-0\the\day}%
   \else
-    \xdef\hyxmp at today{\hyxmp at today-\the\day}%
+    \xdef#1{#1-\the\day}%
   \fi
 }
 %    \end{macrocode}
@@ -2441,12 +2497,26 @@
 %   timezone from \texttt{\string\string\string\pdfcreationdate}, as
 %   proposed by Florian Breitwieser}
 %    \begin{macrocode}
-\expandafter\ifx\csname pdfcreationdate\endcsname\relax
-  \hyxmp at today@define
-\else
-  \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate}%
-\fi
+\@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}
@@ -2493,8 +2563,23 @@
   }%
   \hyxmp at add@simple at var{pdf:Keywords}{@pdfkeywords}%
   \hyxmp at add@simple at var{pdf:Producer}{@pdfproducer}%
-  \@ifundefined{pdfminorversion}{}{%
-    \hyxmp at add@simple{pdf:PDFVersion}{1.\the\pdfminorversion}%
+  \@ifundefined{pdfvariable}{%
+    \@ifundefined{pdfminorversion}{%
+%    \end{macrocode}
+% Case 1: Neither |\pdfvariable| nor |\pdfminorversion| is defined
+% (\XeLaTeX\ and regular \LaTeX).
+%    \begin{macrocode}
+    }{%
+%    \end{macrocode}
+% Case 2: |\pdfminorversion| is defined (\pdfLaTeX\ and pre-0.85 \LuaLaTeX).
+%    \begin{macrocode}
+      \hyxmp at add@simple{pdf:PDFVersion}{1.\the\pdfminorversion}%
+    }%
+  }{%
+%    \end{macrocode}
+% Case 3: |\pdfvariable| is defined (\LuaLaTeX~0.85+).
+%    \begin{macrocode}
+    \hyxmp at add@simple{pdf:PDFVersion}{1.\the\pdfvariable minorversion}%
   }%
   \hyxmp at add@to at xml{%
 ______</rdf:Description>^^J%
@@ -2799,6 +2884,38 @@
 % \subsubsection{The XMP Basic schema}
 % \label{sec:xmp-basic}
 %
+% \begin{macro}{\hyxmp at define@createdate}
+% \begin{macro}{\hyxmp at createdate}
+% Define |\hyxmp at createdate| as the document's creation date but in
+% \acro{XMP} date format, not \acro{PDF} date format.  We use
+% |\hyxmp at createdate| for the \xmpterm{CreateDate},
+% \xmpterm{ModifyDate}, and \xmpterm{MetadataDate} fields.
+%    \begin{macrocode}
+\newcommand*{\hyxmp at define@createdate}{%
+  \@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 createdate
+    }{%
+%    \end{macrocode}
+% Case 2: |\pdfcreationdate| is defined (\pdfLaTeX\ and pre-0.85 \LuaLaTeX).
+%    \begin{macrocode}
+      \edef\hyxmp at createdate{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate}%
+    }%
+  }{%
+%    \end{macrocode}
+% Case 3: |\pdffeedback| is defined (\LuaLaTeX~0.85+).
+%    \begin{macrocode}
+    \edef\hyxmp at createdate{\expandafter\hyxmp at pdf@to at xmp@date\pdffeedback creationdate}%
+  }%
+}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \begin{macro}{\hyxmp at xmp@basic at schema}
 % Add properties defined by the \acro{XMP} Basic schema to the
 % |\hyxmp at xml| macro.  These include a bunch of dates (all set to the
@@ -2805,6 +2922,10 @@
 % same value) and the base \acro{URL} for the document if specified with
 % \optname{baseurl}.
 % \changes{v2.0}{2012/08/26}{Added this macro}
+% \changes{v3.0}{2016/07/04}{Made the \protect\acro{XMP}
+%   \protect\xmpterm{CreateDate}, \protect\xmpterm{ModifyDate}, and
+%   \protect\xmpterm{MetadataDate} match the \protect\acro{PDF}
+%   \protect\pdfterm{CreationDate}}
 %    \begin{macrocode}
 \newcommand*{\hyxmp at xmp@basic at schema}{%
   \hyxmp at add@to at xml{%
@@ -2811,9 +2932,10 @@
 ______<rdf:Description rdf:about=""^^J%
 ____________xmlns:xmp="http://ns.adobe.com/xap/1.0/">^^J%
   }%
-  \hyxmp at add@simple{xmp:CreateDate}{\hyxmp at today}%
-  \hyxmp at add@simple{xmp:ModifyDate}{\hyxmp at today}%
-  \hyxmp at add@simple{xmp:MetadataDate}{\hyxmp at today}%
+  \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}%
   \hyxmp at add@simple{xmp:CreatorTool}{\@pdfcreator}%
   \hyxmp at add@simple{xmp:BaseURL}{\@baseurl}%
   \hyxmp at add@to at xml{%
@@ -3205,22 +3327,27 @@
   \ifx\hyxmp at driver\Hy at driver
     \hyxmp at embed@packet at pdftex
   \else
-    \def\hyxmp at driver{hdvipdfm}%
+    \def\hyxmp at driver{hluatex}%
     \ifx\hyxmp at driver\Hy at driver
-      \hyxmp at embed@packet at dvipdfm
+      \hyxmp at embed@packet at luatex
     \else
-      \def\hyxmp at driver{hxetex}%
+      \def\hyxmp at driver{hdvipdfm}%
       \ifx\hyxmp at driver\Hy at driver
-        \hyxmp at embed@packet at xetex
+        \hyxmp at embed@packet at dvipdfm
       \else
-        \@ifundefined{pdfmark}{%
-          \PackageWarningNoLine{hyperxmp}{%
-            Unrecognized hyperref driver `\Hy at driver'.\MessageBreak
-            \jobname.tex's XMP metadata will *not* be\MessageBreak
-            embedded in the resulting file}%
-        }{%
-          \hyxmp at embed@packet at pdfmark
-        }%
+        \def\hyxmp at driver{hxetex}%
+        \ifx\hyxmp at driver\Hy at driver
+          \hyxmp at embed@packet at xetex
+        \else
+          \@ifundefined{pdfmark}{%
+            \PackageWarningNoLine{hyperxmp}{%
+              Unrecognized hyperref driver `\Hy at driver'.\MessageBreak
+              \jobname.tex's XMP metadata will *not* be\MessageBreak
+              embedded in the resulting file}%
+          }{%
+            \hyxmp at embed@packet at pdfmark
+          }%
+        \fi
       \fi
     \fi
   \fi
@@ -3232,7 +3359,8 @@
 % \subsubsection{Embedding using \pdfTeX}
 %
 % \begin{macro}{\hyxmp at embed@packet at pdftex}
-% Embed the \acro{XMP} packet using \pdfTeX\ primitives.
+% Embed the \acro{XMP} packet using \pdfTeX\ primitives, which are
+% supported by both \pdfTeX\ and pre-0.85 \LuaTeX.
 %    \begin{macrocode}
 \newcommand*{\hyxmp at embed@packet at pdftex}{%
   \bgroup
@@ -3247,6 +3375,52 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \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}
+%    \begin{macrocode}
+\newcommand*{\hyxmp at embed@packet at luatex}{%
+  \luadirect{hyxmp_embed_packet(\luastring{\hyxmp at xml})}%
+  \pdfextension catalog {/Metadata \the\numexpr\pdffeedback lastobj\relax\space 0 R}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsubsection{Embedding using any \texttt{pdfmark}-based backend}
 %
 % \begin{macro}{\hyxmp at embed@packet at pdfmark}

Modified: trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty	2016-07-04 21:57:35 UTC (rev 41625)
+++ trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty	2016-07-04 21:57:47 UTC (rev 41626)
@@ -22,7 +22,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{hyperxmp}
-    [2016/04/27 v2.9 Store hyperref metadata in XMP format]
+    [2016/07/04 v3.0 Store hyperref metadata in XMP format]
 
 \edef\hyxmp at dq@code{\the\catcode`\"}
 \catcode`\"=12
@@ -576,7 +576,7 @@
 \bgroup
   \xdef\hyxmp at xml{}%
   \hyxmp at add@to at xml{%
-__________________________________________________^^J%
+_______________________________________________________________^^J%
   }
   \xdef\hyxmp at padding{\hyxmp at xml}%
 \egroup
@@ -606,24 +606,28 @@
 \def\hyxmp at parse@tz#1'#2'{%
   #1:#2%
 }
-\def\hyxmp at today@define{%
-  \xdef\hyxmp at today{\the\year}%
+\def\hyxmp at today@define#1{%
+  \xdef#1{\the\year}%
   \ifnum\month<10
-    \xdef\hyxmp at today{\hyxmp at today-0\the\month}%
+    \xdef#1{#1-0\the\month}%
   \else
-    \xdef\hyxmp at today{\hyxmp at today-\the\month}%
+    \xdef#1{#1-\the\month}%
   \fi
   \ifnum\day<10
-    \xdef\hyxmp at today{\hyxmp at today-0\the\day}%
+    \xdef#1{#1-0\the\day}%
   \else
-    \xdef\hyxmp at today{\hyxmp at today-\the\day}%
+    \xdef#1{#1-\the\day}%
   \fi
 }
-\expandafter\ifx\csname pdfcreationdate\endcsname\relax
-  \hyxmp at today@define
-\else
-  \edef\hyxmp at today{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate}%
-\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{%
@@ -632,8 +636,13 @@
   }%
   \hyxmp at add@simple at var{pdf:Keywords}{@pdfkeywords}%
   \hyxmp at add@simple at var{pdf:Producer}{@pdfproducer}%
-  \@ifundefined{pdfminorversion}{}{%
-    \hyxmp at add@simple{pdf:PDFVersion}{1.\the\pdfminorversion}%
+  \@ifundefined{pdfvariable}{%
+    \@ifundefined{pdfminorversion}{%
+    }{%
+      \hyxmp at add@simple{pdf:PDFVersion}{1.\the\pdfminorversion}%
+    }%
+  }{%
+    \hyxmp at add@simple{pdf:PDFVersion}{1.\the\pdfvariable minorversion}%
   }%
   \hyxmp at add@to at xml{%
 ______</rdf:Description>^^J%
@@ -774,14 +783,26 @@
 ______</rdf:Description>^^J%
   }%
 }
+\newcommand*{\hyxmp at define@createdate}{%
+  \@ifundefined{pdffeedback}{%
+    \@ifundefined{pdfcreationdate}{%
+      \hyxmp at today@define\hyxmp at createdate
+    }{%
+      \edef\hyxmp at createdate{\expandafter\hyxmp at pdf@to at xmp@date\pdfcreationdate}%
+    }%
+  }{%
+    \edef\hyxmp at createdate{\expandafter\hyxmp at pdf@to at xmp@date\pdffeedback creationdate}%
+  }%
+}
 \newcommand*{\hyxmp at xmp@basic at schema}{%
   \hyxmp at add@to at xml{%
 ______<rdf:Description rdf:about=""^^J%
 ____________xmlns:xmp="http://ns.adobe.com/xap/1.0/">^^J%
   }%
-  \hyxmp at add@simple{xmp:CreateDate}{\hyxmp at today}%
-  \hyxmp at add@simple{xmp:ModifyDate}{\hyxmp at today}%
-  \hyxmp at add@simple{xmp:MetadataDate}{\hyxmp at today}%
+  \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}%
   \hyxmp at add@simple{xmp:CreatorTool}{\@pdfcreator}%
   \hyxmp at add@simple{xmp:BaseURL}{\@baseurl}%
   \hyxmp at add@to at xml{%
@@ -990,22 +1011,27 @@
   \ifx\hyxmp at driver\Hy at driver
     \hyxmp at embed@packet at pdftex
   \else
-    \def\hyxmp at driver{hdvipdfm}%
+    \def\hyxmp at driver{hluatex}%
     \ifx\hyxmp at driver\Hy at driver
-      \hyxmp at embed@packet at dvipdfm
+      \hyxmp at embed@packet at luatex
     \else
-      \def\hyxmp at driver{hxetex}%
+      \def\hyxmp at driver{hdvipdfm}%
       \ifx\hyxmp at driver\Hy at driver
-        \hyxmp at embed@packet at xetex
+        \hyxmp at embed@packet at dvipdfm
       \else
-        \@ifundefined{pdfmark}{%
-          \PackageWarningNoLine{hyperxmp}{%
-            Unrecognized hyperref driver `\Hy at driver'.\MessageBreak
-            \jobname.tex's XMP metadata will *not* be\MessageBreak
-            embedded in the resulting file}%
-        }{%
-          \hyxmp at embed@packet at pdfmark
-        }%
+        \def\hyxmp at driver{hxetex}%
+        \ifx\hyxmp at driver\Hy at driver
+          \hyxmp at embed@packet at xetex
+        \else
+          \@ifundefined{pdfmark}{%
+            \PackageWarningNoLine{hyperxmp}{%
+              Unrecognized hyperref driver `\Hy at driver'.\MessageBreak
+              \jobname.tex's XMP metadata will *not* be\MessageBreak
+              embedded in the resulting file}%
+          }{%
+            \hyxmp at embed@packet at pdfmark
+          }%
+        \fi
       \fi
     \fi
   \fi
@@ -1020,6 +1046,28 @@
     \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})}%
+  \pdfextension catalog {/Metadata \the\numexpr\pdffeedback lastobj\relax\space 0 R}%
+}
 \newcommand*{\hyxmp at embed@packet at pdfmark}{%
   \pdfmark{%
     pdfmark=/NamespacePush



More information about the tex-live-commits mailing list