[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: info dict (95d4a53)
Ulrike Fischer
fischer at troubleshooting-tex.de
Wed May 1 21:12:19 CEST 2019
Repository : https://github.com/latex3/pdfresources
On branch : testlinkstuff
Link : https://github.com/latex3/pdfresources/commit/95d4a536be90d4d800b4301df8a00adf666f6f11
>---------------------------------------------------------------
commit 95d4a536be90d4d800b4301df8a00adf666f6f11
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Wed May 1 21:12:19 2019 +0200
info dict
>---------------------------------------------------------------
95d4a536be90d4d800b4301df8a00adf666f6f11
hluatex-experimental.def | 74 ++++++++++++++++++++++++----------------------
pdfresources.dtx | 40 ++++++++++++++++++++++---
2 files changed, 75 insertions(+), 39 deletions(-)
diff --git a/hluatex-experimental.def b/hluatex-experimental.def
index 03c66b5..1f7eb0c 100644
--- a/hluatex-experimental.def
+++ b/hluatex-experimental.def
@@ -8,7 +8,7 @@
\ProvidesFile{hluatex-experimental.def}
[2019/04/07 v0.2 %
Hyperref driver for luaTeX]
-\RequirePackage{xparse}
+\RequirePackage{xparse,etoolbox}
%%\Hy at VersionCheck{hluatex.def}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -19,6 +19,8 @@
{hyp}
{missing-bookmark-package}
{ The~bookmark~package~is~required~for~this~hyperref~driver!}
+
+
%% I require the bookmark package to get rid of some of the bookmarks code.
\AtEndOfPackage{% so that we are later than KOMA ...
\AtBeginDocument
@@ -725,47 +727,49 @@
}
+\cs_new:Npn \__hyp_info_generate_addons:
+ {
+ \group_begin:
+ \cs_set:Npn \HyInfo at do##1{%
+ \EdefEscapeName\HyInfo at Key{##1}%
+ \pdf_info_gput:on {\HyInfo at Key}{(\csname HyInfo at Value@##1\endcsname)}
+ }
+ \HyInfo at AddonList
+ \group_end:
+ }
+
+
+\def\PDF at FinishDoc{}%
-\def\PDF at FinishDoc{%
- \pdf at ifdraftmode{}{%
+\AtEndPreamble{
+ \pdf at ifdraftmode{}{
\Hy at UseMaketitleInfos
- \HyInfo at GenerateAddons
- \pdf_info_gput:nn
- {Author}{(\@pdfauthor)}
- \pdf_info_gput:nn
- {Title}{(\@pdftitle)}
- \pdf_info_gput:nn
- {Subject}{(\@pdfsubject)}
- \pdf_info_gput:nn
- {Creator}{(\@pdfcreator)} %hm should hyperref set this in any case??
+ \__hyp_info_generate_addons:
+ \pdf_info_string_gput:no
+ {Author} {\@pdfauthor}
+ \pdf_info_string_gput:no
+ {Title} {\@pdftitle}
+ \pdf_info_string_gput:no
+ {Subject}{\@pdfsubject}
+ \pdf_info_string_gput:no
+ {Creator}{\@pdfcreator}
+ \pdf_info_string_gput:no
+ {CreationDate}{\@pdfcreationdate}
+ \pdf_info_string_gput:no
+ {ModDate}{\@pdfmoddate}
+ \tl_if_exist:NT \@pdfproducer %special, as \relax is default
+ {
+ \pdf_info_string_gput:no
+ {Producer}{\@pdfproducer}
+ }
+ \pdf_info_string_gput:no
+ {Keywords}{\@pdfkeywords}
\tl_if_empty:NF
- {\@pdfcreationdate}
- {
- \pdf_info_gput:nn
- {CreationDate}{(\@pdfcreationdate)}
- }
- \tl_if_empty:NF
- \@pdfmoddate
- {
- \pdf_info_gput:nn
- {ModDate}{(\@pdfmoddate)}
- }
- \tl_if_exist:NT %special, as \relax is default
- \@pdfproducer
- {
- \pdf_info_gput:nn
- {Producer}{(\@pdfproducer)}
- }
- \pdf_info_gput:nn
- {Keywords}{(\@pdfkeywords)}
- \tl_if_empty:NF
- {\@pdftrapped}
+ \@pdftrapped
{
\pdf_info_gput:nn
{Trapped}{/\@pdftrapped}
}
- %\HyInfo at Addons % unclear ....needs probably change in hyperref
- \pdf_info_out: % where should this go????
}
\Hy at DisableOption{pdfauthor}%
\Hy at DisableOption{pdftitle}%
diff --git a/pdfresources.dtx b/pdfresources.dtx
index a71da8d..a9c4bc2 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -31,7 +31,7 @@
% \fi
%
% \begin{macrocode}
-\RequirePackage{expl3}
+\RequirePackage{xparse}
\ProvidesExplPackage {pdfresources} {2019-03-17} {0.1}
{experimental pdf-resource management}
% \end{macrocode}
@@ -75,6 +75,14 @@
%
% \subsection{\pkg{media9}}
%
+% \section{Helper code (temporarly!!)}
+% \begin{macrocode}
+%<*package>
+\prg_new_conditional:Npnn \legacy_if:n #1 {p, T , F , TF }
+ { \exp_args:Nc\if_meaning:w { if#1 } \iftrue \prg_return_true:
+ \else: \prg_return_false: \fi: }
+%</package>
+% \end{macrocode}
% \section{New driver Code}
% \subsection{already revisited }
%
@@ -235,8 +243,15 @@
% \subsection{The info dictionary}
% The info dictionary is filled by e.g. \verb+\pdfinfo+. Multiple appearances of
% \verb+\pdfinfo+ are concatenated, so one could end with multiple /Title or /Author entries.
-% It is then viewer dependant which one is showed, so it is better to avoid them. We therefore setup a
-% property which is filled and written to the info directory in one go.
+% It is then viewer dependant which one is showed, so it is better to avoid them.
+% We therefore setup a property which is filled and written to the info
+% directory in one go. According to hyperref a few odd drivers (hvtex, dvipsone, dviwind)
+% don't support arbitrary keys, but this should be handle elsewhere. Most entries are
+% strings so there is a special command for this, as entries with empty content
+% should be ommited we add a test. The string command should perhaps escape the argument???
+% hyperref write the info dictionary as the shipout of the first page --
+% probably to catch the case that \verb+\title+ is issued after the begin of the document.
+% We are outputting at begin document, so all info keys should be set before.
% \begin{macrocode}
%<*package>
\prop_new:N \g_@@_info_dict_prop
@@ -245,11 +260,28 @@
\prop_gput:Nnn\g_@@_info_dict_prop { #1 } { #2 }
}
-\cs_new_protected:Npn \pdf_info_out: %internal? How to ensure that it is used only once?
+\cs_generate_variant:Nn \pdf_info_gput:nn {o}
+
+\cs_new_protected:Npn \pdf_info_string_gput:nn #1 #2 %#1 key without /, #2 content
+ {
+ \tl_if_empty:nF { #2 }
+ {
+ \prop_gput:Nnn\g_@@_info_dict_prop { #1 } { (#2) }
+ }
+ }
+
+\cs_generate_variant:Nn \pdf_info_string_gput:nn {no,oo,on}
+
+
+\cs_new_protected:Npn \@@_info_out: %internal, to ensure that it is used only once
{
\prop_map_function:NN \g_@@_info_dict_prop \driver_pdf_info_gput:nn
+ \prop_clear:N \g_@@_info_dict_prop
}
+\AtBeginDocument{\@@_info_out:}
+
+
%</package>
% \end{macrocode}
% \subsection{The catalog dictionary}
More information about the latex3-commits
mailing list