[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: storing (but driver currently wrong ... (285dbb3)
Ulrike Fischer
fischer at troubleshooting-tex.de
Mon Apr 29 12:42:18 CEST 2019
Repository : https://github.com/latex3/pdfresources
On branch : testlinkstuff
Link : https://github.com/latex3/pdfresources/commit/285dbb3a58c8b9fff74d8b77e1ff425bf8bf3463
>---------------------------------------------------------------
commit 285dbb3a58c8b9fff74d8b77e1ff425bf8bf3463
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Mon Apr 29 12:42:18 2019 +0200
storing (but driver currently wrong ...
>---------------------------------------------------------------
285dbb3a58c8b9fff74d8b77e1ff425bf8bf3463
experiments/manage-pdfpagesattr.tex | 5 +-
hluatex-experimental.def | 15 ++--
pdfresources.dtx | 139 ++++++++++++++++++++++-------------
test-destinations.tex | 33 +++++++++
test-pdfresources.tex | 31 ++++----
5 files changed, 146 insertions(+), 77 deletions(-)
diff --git a/experiments/manage-pdfpagesattr.tex b/experiments/manage-pdfpagesattr.tex
index 5c8933e..c2100b4 100644
--- a/experiments/manage-pdfpagesattr.tex
+++ b/experiments/manage-pdfpagesattr.tex
@@ -1,5 +1,5 @@
\documentclass{report}
-%management of \pagesattr (plural, only one token per document!)
+% management of \pagesattr (plural, only one token per document!)
\usepackage{expl3}
\ExplSyntaxOn
\driver_pdf_compresslevel:n {0}
@@ -9,7 +9,7 @@
{
\cs_if_exist:NTF \tex_variable:D
{ \tex_variable:D pagesattr ~ {#1}}
- { \pdfpagesattr {#1}}
+ { \tex_pdfpagesattr:D {#1}}
}
\cs_generate_variant:Nn \__driver_pdf_pagesattr:n {x}
@@ -32,6 +32,7 @@
%function to remove an attribute?
%function to clear the whole attribute?
%function to check if a key is there and what value it has?
+\show\tex_pdfpageattr:D
\ExplSyntaxOff
\begin{document}
\ExplSyntaxOn
diff --git a/hluatex-experimental.def b/hluatex-experimental.def
index 82d53f8..64a5e18 100644
--- a/hluatex-experimental.def
+++ b/hluatex-experimental.def
@@ -680,13 +680,12 @@
\process at me
\fi
\Hy at pstringdef\Hy at pstringB{\@baseurl}%
- \driver_pdf_catalog:n{%
- /PageMode/\@pdfpagemode
- \ifx\@baseurl\@empty
- \else
- /URI<</Base(\Hy at pstringB)>>%
- \fi
- }%
+ \pdf_catalog_gput:nn {PageMode}{/\@pdfpagemode}
+ \tl_if_empty:NF \@baseurl
+ {
+ \pdf_catalog_gput:nn {URI}{<</Base(\Hy at pstringB)>>}
+ }
+ %
\ifx\@pdfstartpage\@empty
\else
\ifx\@pdfstartview\@empty
@@ -756,7 +755,7 @@
{
/ModDate(\@pdfmoddate)
}
- \tl_if_exist:NT
+ \tl_if_exist:NT %special, as \relax is default
\@pdfproducer
{
/Producer(\@pdfproducer)
diff --git a/pdfresources.dtx b/pdfresources.dtx
index 6701328..2c4fcbe 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -127,17 +127,11 @@
\sys_if_engine_pdftex:T
{
- \cs_new_protected:Nn \driver_pdf_catalog:n
+ \cs_new_protected:Nn \driver_pdf_docview:nn %#1 page number, #2 e.g. /FitH
{
- \pdfcatalog { #1 }
+ \pdfcatalog { } openaction~goto~page #1 {#2}
}
- \cs_new_protected:Nn \driver_pdf_info:n
- {
- \pdfinfo { #1 }
- }
-
-
% this needs refinement, probably is should create named objects and add
% them to the properties, see discussion
@@ -164,18 +158,11 @@
{
%allow version 2.0 in luatex. Needs sorting out later.
\@namedef{Hy at pdfversion@2.0}{10}%
- \cs_new_protected:Nn \driver_pdf_catalog:n
+ \cs_new_protected:Nn \driver_pdf_docview:nn %#1 page number, #2 e.g. /FitH
{
- \pdfextension catalog { #1 }
+ \pdfextension catalog { } openaction~goto~page #1 {#2}
}
- \cs_new_protected:Nn \driver_pdf_info:n
- {
- \pdfextension info { #1 }
- }
-
-
-
\cs_new_protected:Npx \driver_pdf_bdc:nn #1 #2
{
\cs_if_exist:NTF \tex_pdfextension:D
@@ -223,6 +210,56 @@
% \end{macrocode}
% \section{Management code / pdf Module}
%<@@=pdf>
+% \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 at begin document.
+% \begin{macrocode}
+%<*package>
+\prop_new:N \g_@@_info_dict_prop
+\cs_new_protected:Npn \pdf_info_gput:nn #1 #2 %#1 key without /, #2 content
+ {
+ \prop_gput:Nnn\g_@@_info_dict_prop { #1 } { #2 }
+ }
+\AtBeginDocument
+ {
+ \prop_map_function:NN \g_@@_info_dict_prop \driver_pdf_info_gput:nn
+ }
+%</package>
+% \end{macrocode}
+% \subsection{The catalog dictionary}
+% The catalog dictionary is filled by e.g. \verb+\pdfcatalog+. Multiple appearances of
+% \verb+\pdfcatalog+ are concatenated, so one could end with multiple entries.
+% We is better to avoid this. We therefore setup a
+% property which is filled and executed in one go at begin document.
+% \verb+\pdfcatalog+ has an option \texttt{openaction} to set the start view options. This is ignored
+% here but set in a separate command (to be in sync with other drivers).
+% \begin{macrocode}
+%<*package>
+\prop_new:N \g_@@_catalog_dict_prop
+\cs_new_protected:Npn \pdf_catalog_gput:nn #1 #2 %#1 key without /, #2 content
+ {
+ \prop_gput:Nnn\g_@@_catalog_dict_prop { #1 } { #2 }
+ }
+\AtBeginDocument
+ {
+ \prop_map_function:NN \g_@@_catalog_dict_prop \driver_pdf_catalog_gput:nn
+ }
+%</package>
+% \end{macrocode}
+% \subsection{Doc View}
+% This commands set Doc View options. This is rather crude /needs review. For now we
+% assume that only the equivalent of \verb+openaction~goto~page\@pdfstartpage{\@pdfstartview}+ in
+% hyperref is needed. The format of the second argument is quite unclear (slash, casing).
+% \begin{macrocode}
+%<*package>
+\cs_new_protected:Npn \pdf_docview:nn #1 #2
+ {
+ \driver_pdf_docview:nn {#1}{#2}
+ }
+%</package>
+% \end{macrocode}
% \subsection{Setting / comparing pdf versions}
% The code assumes that the versions are two integers separated by a period.
%
@@ -232,7 +269,7 @@
%<*package>
\cs_new_protected:Npn \pdf_version_gset:n #1
{
- \__pdf_version_gset:w #1 . . \q_stop
+ \@@_version_gset:w #1 . . \q_stop
}
\cs_new_protected:Npn \pdf_version_min_gset:n #1
@@ -316,7 +353,7 @@
% their code to the \texttt{attr} argument through hooks.
% \begin{macrocode}
%<*package>
-\cs_new:Nn \__pdf_get_key_value:nn { #1~#2~ } %name?????
+\cs_new:Nn \@@_get_key_value:nn { #1~#2~ } %name?????
%</package>
% \end{macrocode}
% Attributes are stored in a property list. Packages can add attributes through
@@ -327,11 +364,11 @@
%
% \begin{macrocode}
%<*package>
-\prop_new:N\l__pdf_hook_link_begin_url_attr_prop %\hyper at linkurl
-\prop_new:N\l__pdf_hook_link_begin_file_attr_prop %\hyper at linkfile
-\prop_new:N\l__pdf_hook_link_begin_run_attr_prop %\@hyper at launch run
-\prop_new:N\l__pdf_hook_link_begin_link_attr_prop %\hyper at link, \find at pdflink
-\prop_new:N\l__pdf_hook_link_begin_menu_attr_prop %\Acrobatmenu
+\prop_new:N\l_@@_hook_link_begin_url_attr_prop %\hyper at linkurl
+\prop_new:N\l_@@_hook_link_begin_file_attr_prop %\hyper at linkfile
+\prop_new:N\l_@@_hook_link_begin_run_attr_prop %\@hyper at launch run
+\prop_new:N\l_@@_hook_link_begin_link_attr_prop %\hyper at link, \find at pdflink
+\prop_new:N\l_@@_hook_link_begin_menu_attr_prop %\Acrobatmenu
%</package>
% \end{macrocode}
%
@@ -343,19 +380,19 @@
%<*package>
\cs_new_protected:Nn \pdf_link_user:nnn %#1 type (url, file etc, #2 action spec, #3 link text
{
- \seq_if_exist:cT { l__pdf_hook_link_begin_#1_seq }
+ \seq_if_exist:cT { l_@@_hook_link_begin_#1_seq }
{
- \seq_use:cn { l__pdf_hook_link_begin_#1_seq }{}
+ \seq_use:cn { l_@@_hook_link_begin_#1_seq }{}
}
\mode_leave_vertical:
%\driver_pdf_link_user:nnn
\driver_pdf_link_begin_user:nnw
{
- \prop_if_exist:cT { l__pdf_hook_link_begin_#1_attr_prop }
+ \prop_if_exist:cT { l_@@_hook_link_begin_#1_attr_prop }
{
\prop_map_function:cN
- { l__pdf_hook_link_begin_#1_attr_prop }
- \__pdf_get_key_value:nn
+ { l_@@_hook_link_begin_#1_attr_prop }
+ \@@_get_key_value:nn
}
}
{
@@ -363,7 +400,7 @@
}
#3
\driver_pdf_link_end:
- \seq_use:cn { l__pdf_hook_link_end_#1_seq }{}
+ \seq_use:cn { l_@@_hook_link_end_#1_seq }{}
}
%</package>
% \end{macrocode}
@@ -371,17 +408,17 @@
%<*package>
\cs_new_protected:Npn \pdf_link_begin_user:nnw #1 #2 %#1 type, #2 action spec
{
- \seq_if_exist:cT { l__pdf_hook_link_begin_#1_seq }
+ \seq_if_exist:cT { l_@@_hook_link_begin_#1_seq }
{
- \seq_use:cn { l__pdf_hook_link_begin_#1_seq }{}
+ \seq_use:cn { l_@@_hook_link_begin_#1_seq }{}
}
\driver_pdf_link_begin_user:nnw
{
- \prop_if_exist:cT { l__pdf_hook_link_begin_#1_attr_prop }
+ \prop_if_exist:cT { l_@@_hook_link_begin_#1_attr_prop }
{
\prop_map_function:cN
- { l__pdf_hook_link_begin_#1_attr_prop }
- \__pdf_get_key_value:nn
+ { l_@@_hook_link_begin_#1_attr_prop }
+ \@@_get_key_value:nn
}
}
{ #2 }
@@ -390,17 +427,17 @@
% At second one with the \texttt{goto name} argument:
\cs_new_protected:Npn \pdf_link_begin_goto:nnw #1 #2 %#1 type, #2 destination
{
- \seq_if_exist:cT { l__pdf_hook_link_begin_#1_seq }
+ \seq_if_exist:cT { l_@@_hook_link_begin_#1_seq }
{
- \seq_use:cn { l__pdf_hook_link_begin_#1_seq }{}
+ \seq_use:cn { l_@@_hook_link_begin_#1_seq }{}
}
\driver_pdf_link_begin_goto:nnw
{
- \prop_if_exist:cT { l__pdf_hook_link_begin_#1_attr_prop }
+ \prop_if_exist:cT { l_@@_hook_link_begin_#1_attr_prop }
{
\prop_map_function:cN
- { l__pdf_hook_link_begin_#1_attr_prop }
- \__pdf_get_key_value:nn
+ { l_@@_hook_link_begin_#1_attr_prop }
+ \@@_get_key_value:nn
}
}
{ #2 }
@@ -425,18 +462,18 @@
% add and remove hooks by index. The hook depends on the type.
% \begin{macrocode}
%<*package>
-\seq_new:N \l__pdf_hook_link_end_url_seq
-\seq_new:N \l__pdf_hook_link_end_run_seq
-\seq_new:N \l__pdf_hook_link_end_file_seq
-\seq_new:N \l__pdf_hook_link_end_link_seq
-\seq_new:N \l__pdf_hook_link_end_menu_seq
+\seq_new:N \l_@@_hook_link_end_url_seq
+\seq_new:N \l_@@_hook_link_end_run_seq
+\seq_new:N \l_@@_hook_link_end_file_seq
+\seq_new:N \l_@@_hook_link_end_link_seq
+\seq_new:N \l_@@_hook_link_end_menu_seq
\cs_new_protected:Nn \pdf_link_end:n %#1 type, e.g. url
{
\driver_pdf_link_end:
- \seq_if_exist:cT {l__pdf_hook_link_end_#1_seq}
+ \seq_if_exist:cT {l_@@_hook_link_end_#1_seq}
{
- \seq_use:cn { l__pdf_hook_link_end_#1_seq }{}
+ \seq_use:cn { l_@@_hook_link_end_#1_seq }{}
}
}
@@ -447,10 +484,10 @@
% setup hooks for this too:
% \begin{macrocode}
%<*package>
-\seq_new:N \l__pdf_hook_link_begin_url_seq
-\seq_new:N \l__pdf_hook_link_begin_run_seq
-\seq_new:N \l__pdf_hook_link_begin_file_seq
-\seq_new:N \l__pdf_hook_link_begin_link_seq
+\seq_new:N \l_@@_hook_link_begin_url_seq
+\seq_new:N \l_@@_hook_link_begin_run_seq
+\seq_new:N \l_@@_hook_link_begin_file_seq
+\seq_new:N \l_@@_hook_link_begin_link_seq
%</package>
% \end{macrocode}
%
diff --git a/test-destinations.tex b/test-destinations.tex
new file mode 100644
index 0000000..4bd03c6
--- /dev/null
+++ b/test-destinations.tex
@@ -0,0 +1,33 @@
+% !Mode:: "TeX:DE:UTF-8:Main"
+
+
+
+\documentclass{article}
+\usepackage{expl3}
+
+\usepackage{pdfresources}
+
+%don't compress pdf:
+\ExplSyntaxOn
+\driver_pdf_compresslevel:n {0}
+\driver_pdf_objects_disable:
+\ExplSyntaxOff
+\usepackage{xcolor}
+
+\usepackage[customdriver=hluatex-experimental,pdfview=Fith]{hyperref}
+
+
+\hypupdateattribute
+\begin{document}
+
+
+\section{a}\label{a}
+
+\hypersetup{pdfview=xyz 50}
+\section{b}\label{b}
+\newpage
+\ref{a} \quad \ref{b}
+
+
+
+\end{document}
diff --git a/test-pdfresources.tex b/test-pdfresources.tex
index 160eacf..ce9bcab 100644
--- a/test-pdfresources.tex
+++ b/test-pdfresources.tex
@@ -5,22 +5,28 @@
\documentclass{article}
\usepackage{expl3}
+\makeatletter
+\@namedef{Hy at pdfversion@2.0}{10}%
+\makeatother%
\usepackage{pdfresources}
%don't compress pdf:
\ExplSyntaxOn
\driver_pdf_compresslevel:n {0}
\driver_pdf_objects_disable:
+
+%\driver_pdf_catalog_gput:nn {Lang}
\ExplSyntaxOff
\usepackage{xcolor}
-\showthe\luatexversion
-\makeatletter
-\@namedef{Hy at pdfversion@2.0}{10}%
-\makeatother%
-\usepackage[customdriver=hluatex-experimental,ocgcolorlinks,pdfversion=2.0]{hyperref}
+\usepackage[customdriver=hluatex-experimental,pdfversion=2.0,pdftitle=X]{hyperref}
+\ExplSyntaxOn
+\driver_pdf_info_gput:nn{Title}{(A)}
+\driver_pdf_info_gput:nn{Title}{(B)}
+\driver_pdf_info_gput:nn{Title}{(C)}
+\ExplSyntaxOff
%%\tracingmacros=1
-\hypersetup{urlcolor=blue,linkbordercolor=blue,pdfborder={1 1 1},pdfprintpagerange=0}
+\hypersetup{urlbordercolor=blue,linkbordercolor=green,pdfborder={1 1 1},pdfprintpagerange=0}
%%%\makeatletter
\hypupdateattribute
\makeatletter%\tracingmacros=1
@@ -30,15 +36,7 @@
abc%\end{document}
\ExplSyntaxOn
-\tl_set:Nx\l_tmpa_tl
- {
- LuaTeX-
- \int_div_truncate:nn{\luatexversion}{100}.
- \int_compare:nNnT {\int_mod:nn{\luatexversion}{100}}<{10}{0}
- \int_mod:nn{\luatexversion}{100}.
- \luatexrevision
- }
-\tl_show:N\l_tmpa_tl
+
\driver_pdf_link_begin_user:nnw{}{/A<</Type/Action/S/URI/URI(www.blub.de)>>}
\driver_pdf_link_end:
@@ -76,7 +74,8 @@ xxx
\url{www.blubblubblub.de}
\section{a}\label{a}
-\ref{a}
+\newpage
+\ref{a} \quad
\ExplSyntaxOff
\Acrobatmenu{Find}{Find}
%\hyperlink{blblb}{yabc\\xye\\abc}
More information about the latex3-commits
mailing list