texlive[56839] Master/texmf-dist: hyperxmp (2nov20)

commits+karl at tug.org commits+karl at tug.org
Mon Nov 2 22:55:35 CET 2020


Revision: 56839
          http://tug.org/svn/texlive?view=revision&revision=56839
Author:   karl
Date:     2020-11-02 22:55:35 +0100 (Mon, 02 Nov 2020)
Log Message:
-----------
hyperxmp (2nov20)

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	2020-11-02 21:55:19 UTC (rev 56838)
+++ trunk/Master/texmf-dist/source/latex/hyperxmp/hyperxmp.dtx	2020-11-02 21:55:35 UTC (rev 56839)
@@ -22,7 +22,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{hyperxmp}
 %<*package>
-    [2020/10/05 v5.6 Store hyperref metadata in XMP format]
+    [2020/11/01 v5.7 Store hyperref metadata in XMP format]
 %</package>
 %
 %<*driver>
@@ -264,6 +264,8 @@
 % \newcounter{note}
 % \newcommand{\usagenote}[1]{^^A
 %   \refstepcounter{note}^^A
+%   \Needspace{\baselineskip}^^A
+%   \belowpdfbookmark{Note \thenote: #1}{note.\thenote}^^A
 %   \paragraph{Note~\thenote: #1}%
 % }
 %
@@ -302,6 +304,9 @@
 % \DeclareRobustCommand{\Dvips}{^^A
 %   \texorpdfstring{Dvips\SortIndex{dvips}{\texttt{dvips}}}{Dvips}^^A
 % }
+% \DeclareRobustCommand{\progname}[1]{^^A
+%   \texttt{#1}\SortIndex{#1}{\texttt{#1}}^^A
+% }
 % \DeclareRobustCommand{\Lua}{^^A
 %   Lua\index{Lua}^^A
 % }
@@ -1338,8 +1343,8 @@
 % via the \Koma\ letter classes (e.g.,~\clsname{scrlttr2}) and the
 % \ACMclass\ article class (\clsname{acmart}).
 %
-% If a document uses either or \pkgname{babel} or \pkgname{polyglossia}
-% package, it is recommended that it \emph{not} explicitly set
+% If a document uses either the \pkgname{babel} or \pkgname{polyglossia}
+% packages it is recommended that it \emph{not} explicitly set
 % \optname{pdflang}.  \optname{pdflang} accepts only a single language
 % name while \pkgname{hyperxmp} can automatically query \pkgname{babel}
 % and \pkgname{polyglossia} for a list of all languages used in the
@@ -1430,6 +1435,7 @@
 % \pkgname{totpages} package help generate \optname{pdfpagerange}.  For
 % documents numbered from~1 to~$n$, a simple
 %
+% \Needspace{3\baselineskip}
 % \begin{verbatim}
 %     \hypersetup{%
 %       pdfpagerange={1-\ref*{TotPages}}
@@ -1475,7 +1481,78 @@
 %     }
 % \end{verbatim}
 %
+% \usagenote{Automatic computation of the PDF byte count}
+% \label{note:auto-byte-count}
 %
+% The \schema[PRISM Basic Metadata]{\protect\acro{PRISM} Basic Metadata}
+% schema~\cite{PRISM2012:basic-meta} defines a \xmpprop{prism:byteCount}
+% property that indicates the \acro{PDF} file size in bytes.
+% \pkgname{hyperxmp} computes this value automatically when the document
+% is built using \LuaLaTeX\ but not when using any other \TeX\ engine.
+% (Note that \pkgname{hyperxmp} uses the file size from the
+% \emph{previous} run of \LuaLaTeX\ because the new \acro{PDF} file is
+% not yet complete.)
+%
+% The \progname{latexmk} build tool can be configured to automatically
+% append a line of the form ``|\hypersetup{pdfbytes=|\meta{number}|}|''
+% to the generated |.aux| file.  The subsequent build of the document
+% will read the |.aux| file at the end of the preamble and set
+% \optname{pdfbytes} accordingly.  The Perl code shown in
+% Figure~\ref{fig:latexmkrc}, derived from code posted by Nelson Posse
+% Lago and John Collins on
+% \url{https://github.com/borisveytsman/acmart/issues/413}, can be
+% included in a \progname{latexmk} configuration file to set
+% \optname{pdfbytes} automatically whenever \progname{latexmk} builds a
+% \pkgname{hyperxmp}-based document using
+% \pdfLaTeX\ (\progname{latexmk}'s |--pdf| option).  The code can be
+% adapted, \textit{mutatis mutandis}, to work with \XeLaTeX\ builds
+% (\progname{latexmk}'s |--pdfxe| or |--xelatex| option).
+%
+% \iffalse
+%<*listings>
+% \fi
+\begin{figure}
+  \begin{lstlisting}[
+      language=perl,
+      columns=fullflexible,
+      frame=single,
+      basicstyle=\footnotesize,
+      showstringspaces=false
+    ]
+$pdflatex = 'internal mylatex %O %S';
+
+sub mylatex {
+    my @args = @_;
+    $retval = system 'pdflatex', @args;
+    get_pdf_size();
+    return $retval;
+}
+
+sub get_pdf_size {
+    my $size = (stat($out_dir1 . $root_filename . ".pdf"))[7];
+    open(AUX, '>>', $aux_dir1 . $root_filename . ".aux")
+        || die "Can't open file " . $aux_dir1 . $root_filename . ".aux: $!";
+    if (defined($size)) {
+        print AUX "\\\@ifpackageloaded{hyperxmp}{\\hypersetup{pdfbytes=$size}}{}\n";
+    }
+    close(AUX);
+}
+  \end{lstlisting}
+  \caption{Code to include in a \progname{latexmk} configuration file
+    to automate the assignment of \pkgname{hyperxmp}'s
+    \optname{pdfbytes} option when building with \pdfLaTeX}
+  \label{fig:latexmkrc}
+\end{figure}
+% \iffalse
+%</listings>
+% \fi
+%
+% See \href{http://mirrors.ctan.org/support/latexmk/latexmk.pdf}{the
+%   \progname{latexmk} manual} for information on configuration-file
+% naming on different operating systems and explanations of the hooks
+% used in the Figure~\ref{fig:latexmkrc} code.
+%
+%
 % \StopEventually{^^A
 % \section{Help Wanted}
 %
@@ -2653,6 +2730,7 @@
 % \end{macro}
 %
 % \begin{macro}{\hyxmp at concated@metadata}
+% \begin{macro}{\hyxmp at aep@toks}
 % Assume that if the document loaded either \pkgname{babel} or
 % \pkgname{polyglossia} it will eventually define one or more languages
 % that \pkgname{hyperxmp} can list within a \xmpprop{dc:language}
@@ -2675,6 +2753,7 @@
 }
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\hyxmp at warn@if at no@metadata}
 % \begin{macro}{\hyxmp at concated@metadata}
@@ -2792,6 +2871,7 @@
 % \end{macro}
 % \end{macro}
 %
+% \begin{macro}{\hyxmp at aep@toks}
 % Right before we reach the |\begin{document}| we check if
 % \pkgname{hyperref} was loaded.  In normal usage, the document will
 % already have done a |\usepackage{hyperref}| because otherwise,
@@ -2857,6 +2937,7 @@
   }%
 }
 %    \end{macrocode}
+% \end{macro}
 %
 % When we reach the |\end{document}| we need to gather up the metadata
 % specified explicitly by the user, infer additional metadata where
@@ -3094,11 +3175,25 @@
 %    \end{macrocode}
 %
 % Determine the size of the output file from the \emph{previous} run of
-% \LuaLaTeX\ or \pdfLaTeX\@.  This action has to be performed before the
+% \LuaLaTeX\@.  This action has to be performed before the
 % |\begin{document}| because at that point the size of the output file
 % is reset to zero.  We use |\jobname.pdf| as the name of the output
-% file even in the \LuaLaTeX\ case because |status.output_file_name| is
-% not defined at this point.
+% file because |status.output_file_name| is not defined at this point.
+%
+% It's possible to use \pdfLaTeX's \cs{pdffilesize} primitive to query
+% the size of |\jobname.pdf| under \pdfLaTeX\@.  Unfortunately, doing so
+% has a side effect of making \progname{latexmk} view the
+% \acro{PDF} file as an input file, which puts \progname{latexmk} in an
+% infinite build loop.  (This was the case for \pkgname{hyperxmp} v5.5
+% and v5.6.)  See the discussion at
+% \url{https://github.com/borisveytsman/acmart/issues/413} for more
+% information.
+% \changes{v5.7}{2020/11/01}{Do not automatically compute the
+%   \protect\acro{PDF} file size under \protect\pdfLaTeX\ because this confuses
+%   \protect\progname{latexmk}.  Thanks to John Collins, Nelson Posse Lago,
+%   Derek Dreyer, and the other contributors to
+%   \protect\href{https://github.com/borisveytsman/acmart/issues/413}{\protect\pkgname{acmart} issue \#413},
+%   ``Latexmk goes into an infinite loop even on sample files from ACM''}
 %    \begin{macrocode}
 \ifLuaTeX
   \edef\hyxmp at prev@pdf at size{%
@@ -3109,10 +3204,6 @@
 end
     }%
   }%
-\else
-  \ifPDFTeX
-    \edef\hyxmp at prev@pdf at size{\pdffilesize{\hyxmp at jobname.pdf}}%
-  \fi
 \fi
 %    \end{macrocode}
 %
@@ -5609,6 +5700,28 @@
 %
 % \begin{schemadesc}[XMP Media Management]{\protect\acro{XMP} Media Management}
 %
+% \begin{macro}{\hyxmp at aep@toks}
+% Once we reach the end of the preamble and know that \cs{@pdftitle} and
+% \cs{@pdfauthor} are no longer expected to change we use those macros
+% (and others) to define one \acro{UUID} for the document
+% (\cs{hyxmp at DocumentID}) and one for the document instance
+% (\cs{hyxmp at InstanceID}).  As explained in
+% Section~\ref{sec:initial-prep}, we defer the invocation of
+% \cs{AtEndPreamble} to the end of the file.
+% \changes{v5.7}{2020/10/13}{As requested by Moritz Heckscher, define
+%   \protect\cs{hyxmp at DocumentID} and \protect\cs{hyxmp at InstanceID} at
+%   the end of the preamble instead of at the end of the document}
+%    \begin{macrocode}
+\expandafter\hyxmp at aep@toks\expandafter=\expandafter{%
+  \the\hyxmp at aep@toks
+  \AtEndPreamble{%
+    \@ifmtargexp{\hyxmp at DocumentID}{\hyxmp at def@DocumentID}{}%
+    \@ifmtargexp{\hyxmp at InstanceID}{\hyxmp at def@InstanceID}{}%
+  }%
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\hyxmp at mm@schema}
 % Add properties defined by the \acro{XMP} Media Management schema to
 % the |\hyxmp at xml| macro.  According to the \acro{XMP} specification,
@@ -5629,8 +5742,6 @@
 %   the \protect\acro{XMP} packet}
 %    \begin{macrocode}
 \gdef\hyxmp at mm@schema{%
-  \@ifmtargexp{\hyxmp at DocumentID}{\hyxmp at def@DocumentID}{}%
-  \@ifmtargexp{\hyxmp at InstanceID}{\hyxmp at def@InstanceID}{}%
   \hyxmp at add@simple{xmpMM:DocumentID}{\hyxmp at DocumentID}%
   \hyxmp at add@simple{xmpMM:InstanceID}{\hyxmp at InstanceID}%
   \hyxmp at add@simple{xmpMM:VersionID}{\@pdfversionid}%

Modified: trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty	2020-11-02 21:55:19 UTC (rev 56838)
+++ trunk/Master/texmf-dist/tex/latex/hyperxmp/hyperxmp.sty	2020-11-02 21:55:35 UTC (rev 56839)
@@ -22,7 +22,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{hyperxmp}
-    [2020/10/05 v5.6 Store hyperref metadata in XMP format]
+    [2020/11/01 v5.7 Store hyperref metadata in XMP format]
 \edef\hyxmp at dq@code{\the\catcode`\"}
 \catcode`\"=12
 \@ifundefined{AtEndDocument}{%
@@ -513,10 +513,6 @@
 end
     }%
   }%
-\else
-  \ifPDFTeX
-    \edef\hyxmp at prev@pdf at size{\pdffilesize{\hyxmp at jobname.pdf}}%
-  \fi
 \fi
 \newcommand*{\hyxmp at query@self}{%
   \ifLuaTeX
@@ -1459,9 +1455,14 @@
     \hyxmp at add@simple{xmpRights:WebStatement}{\@pdflicenseurl}%
   \fi
 }
+\expandafter\hyxmp at aep@toks\expandafter=\expandafter{%
+  \the\hyxmp at aep@toks
+  \AtEndPreamble{%
+    \@ifmtargexp{\hyxmp at DocumentID}{\hyxmp at def@DocumentID}{}%
+    \@ifmtargexp{\hyxmp at InstanceID}{\hyxmp at def@InstanceID}{}%
+  }%
+}
 \gdef\hyxmp at mm@schema{%
-  \@ifmtargexp{\hyxmp at DocumentID}{\hyxmp at def@DocumentID}{}%
-  \@ifmtargexp{\hyxmp at InstanceID}{\hyxmp at def@InstanceID}{}%
   \hyxmp at add@simple{xmpMM:DocumentID}{\hyxmp at DocumentID}%
   \hyxmp at add@simple{xmpMM:InstanceID}{\hyxmp at InstanceID}%
   \hyxmp at add@simple{xmpMM:VersionID}{\@pdfversionid}%



More information about the tex-live-commits mailing list.