[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: cleaning up, extending driver (7d42fc4)
Ulrike Fischer
fischer at troubleshooting-tex.de
Sat Apr 13 00:57:03 CEST 2019
Repository : https://github.com/latex3/pdfresources
On branch : testlinkstuff
Link : https://github.com/latex3/pdfresources/commit/7d42fc4c1f2b86bddc19f83bc24737a92558432f
>---------------------------------------------------------------
commit 7d42fc4c1f2b86bddc19f83bc24737a92558432f
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sat Apr 13 00:57:03 2019 +0200
cleaning up, extending driver
>---------------------------------------------------------------
7d42fc4c1f2b86bddc19f83bc24737a92558432f
hluatex-experimental.def | 37 ++++++++++---------
pdfresources.dtx | 92 ++++++++++++++++++++++++++++++++++------------
test-pdfresources.tex | 47 ++++++++++++++++++-----
3 files changed, 126 insertions(+), 50 deletions(-)
diff --git a/hluatex-experimental.def b/hluatex-experimental.def
index 94f86aa..9585018 100644
--- a/hluatex-experimental.def
+++ b/hluatex-experimental.def
@@ -19,7 +19,7 @@
{hyp}
{missing-bookmark-package}
{ The~bookmark~package~is~required~for~this~hyperref~driver!}
-%% I'm require the bookmark package to get rid of some of the bookmarks code.
+%% I require the bookmark package to get rid of some of the bookmarks code.
\AtEndOfPackage{% so that we are later than KOMA ...
\AtBeginDocument
{
@@ -237,11 +237,11 @@
\ExplSyntaxOn
\ifHy at ocgcolorlinks
- \ifnum\Hy at pdfminorversion<5 %
- \kvsetkeys{Hyp}{pdfversion=1.5}%
- \fi
+ \pdf_version_min_gset:n { 1.5 }
\fi
\ExplSyntaxOff
+% should this go into the drivers?
+% or in the pdf level?
\ifHy at setpdfversion
\ifnum\Hy at pdfversion<5 %
\ltx at IfUndefined{pdfobjcompresslevel}{%
@@ -431,16 +431,15 @@
\else
\Hy at DisableOption{ocgcolorlinks}
\fi
-\ExplSyntaxOff
-\def\setpdflinkmargin#1{%
- \begingroup
- \setlength{\dimen@}{#1}%
- \expandafter\endgroup
- \expandafter\pdflinkmargin\the\dimen@\relax
-}
+\def\setpdflinkmargin#1
+ {
+ \driver_pdf_link_margin:n { #1 }
+ }
+ % default:
+ \driver_pdf_link_margin:n { 1pt}
+\ExplSyntaxOff
-\pdflinkmargin1pt %
\providecommand*\@pdfview{XYZ}
\Hy at WrapperDef\new at pdflink#1{%
@@ -457,9 +456,13 @@
\fi
}
\let\pdf at endanchor\@empty
-\def\Hy at DestName#1#2{%
- \pdfextension dest name{#1}#2\relax
-}
+
+\ExplSyntaxOn
+\def\Hy at DestName#1#2
+ {
+ \driver_pdf_dest_name:nn {#1}{#2}
+ }
+\ExplSyntaxOff
\providecommand*\@pdfborder{0 0 1}
\providecommand*\@pdfborderstyle{}
\def\Hy at undefinedname{UNDEFINED}
@@ -491,7 +494,7 @@
\ExplSyntaxOn
\def\Hy at StartlinkName#1#2{%
- \pdf_startlink_goto_name:nn { link } { #2 }
+ \pdf_startlink_goto_name:nn { link } { #2 } %%% can this be done without splitting?
}
@@ -524,7 +527,7 @@
% #2 is the destination find at pdflink uses then named link
\def\hyper at linkstart#1#2{%
\Hy at VerboseLinkStart{#1}{#2}% only for debug
- \tl_if_exist:cTF %or test for blank??
+ \tl_if_exist:cTF %or test for blank??
{ @#1bordercolor }
{
\hook_put:nnnn
diff --git a/pdfresources.dtx b/pdfresources.dtx
index d233094..70d4576 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -95,6 +95,7 @@
% \begin{macro}{\driver_pdf_startlink_goto:nn, \driver_pdf_startlink_user:nn}
% \begin{macro}{\@@_pdf_startlink:nnn}
% \begin{macrocode}
+% %% will probably go shortly
\cs_new_protected:Npn \driver_pdf_startlink_goto:nn #1#2
{ \@@_pdf_startlink:nnn {#1} { goto~name } {#2} }
\cs_new_protected:Npn \driver_pdf_startlink_user:nn #1#2
@@ -189,42 +190,36 @@
%<*package>
\sys_if_engine_pdftex:T
{
- \cs_new_protected:Nn \driver_pdf_lastlink:
- {
- \pdflastlink
- }
\cs_new_protected:Nn \driver_pdf_catalog:n
{
\pdfcatalog { #1 }
}
- \cs_new:Npn \driver_pdf_minorversion: { \tex_the:D \tex_pdfminorversion:D }
- \cs_new:Npn \driver_pdf_majorversion: { 1 }
+\cs_new_protected:Nn \driver_pdf_dest_name:nn %#1 name, #2 dest type (e.g. fitbh)
+ {
+ \pdfdest~{#1}#2\scan_stop:
+ }
\input{l3pdfmode-pdf.def}
}
\sys_if_engine_luatex:T
{
- \cs_new_protected:Nn \driver_pdf_lastlink:
- {
- \numexpr\pdffeedback lastlink\relax
- }
-
\cs_new_protected:Nn \driver_pdf_catalog:n
{
\pdfextension catalog { #1 }
}
- \cs_new:Npn \driver_pdf_minorversion: { \tex_the:D \pdfvariable~minorversion }
- \cs_new:Npn \driver_pdf_majorversion: { \tex_the:D \pdfvariable~majorversion }
+\cs_new_protected:Nn \driver_pdf_dest_name:nn %#1 name, #2 dest type (e.g. fitbh)
+ {
+ \pdfextension~dest~name~{#1}#2 \scan_stop:
+ }
\input{l3pdfmode-pdf.def}
}
\sys_if_engine_xetex:T
{
- %% \cs_new_protected:Nn \driver_pdf_startlink_goto_name:nn %????
%% \cs_new_protected:Nn \driver_pdf_catalog:n ????
\input{l3dvipdfmx-pdf.def}
}
@@ -232,8 +227,35 @@
% \end{macrocode}
% \section{Management code / pdf Module}
%<@@=pdf>
-% \subsection{Comparing pdf versions}
+% \subsection{Setting / comparing pdf versions}
% The code assumes that the versions are two integers separated by a period.
+%
+% \begin{macro}{\pdf_version_gset:n, \pdf_version_min_gset:n}
+% \begin{macro}{\@@_version_gset:w}
+% \begin{macrocode}
+%<*package>
+\cs_new_protected:Npn \pdf_version_gset:n #1
+ {
+ \__pdf_version_gset:w #1 . . \q_stop
+ }
+
+\cs_new_protected:Npn \pdf_version_min_gset:n #1
+ {
+ \pdf_version_compare:NnT < {#1}
+ {
+ \@@_version_gset:w #1 . . \q_stop
+ }
+ }
+
+\cs_new_protected:Npn \@@_version_gset:w #1 .#2 . #3\q_stop
+ {
+ \driver_pdf_version_major_gset:n {#1}
+ \driver_pdf_version_minor_gset:n {#2}
+ }
+%</package>
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
% \begin{macro}{\pdf_version_compare:Nn}
% \begin{macrocode}
%<*package>
@@ -241,9 +263,9 @@
{
\bool_if:nTF
{
- \int_compare_p:n { \driver_pdf_majorversion: = #1 }
+ \int_compare_p:n { \driver_pdf_version_major: = #1 }
&&
- \int_compare_p:n { \driver_pdf_minorversion: = #2}
+ \int_compare_p:n { \driver_pdf_version_minor: = #2}
}
{ \prg_return_true: }
{ \prg_return_false: }
@@ -253,12 +275,12 @@
{
\bool_if:nTF
{
- \int_compare_p:n { \driver_pdf_majorversion: < #1}
+ \int_compare_p:n { \driver_pdf_version_major: < #1}
||
(
- \int_compare_p:n { \driver_pdf_majorversion: = #1 }
+ \int_compare_p:n { \driver_pdf_version_major: = #1 }
&&
- \int_compare_p:n { \driver_pdf_minorversion: < #2 }
+ \int_compare_p:n { \driver_pdf_version_minor: < #2 }
)
}
{ \prg_return_true: }
@@ -269,12 +291,12 @@
{
\bool_if:nTF
{
- \int_compare_p:n { \driver_pdf_majorversion: > #1}
+ \int_compare_p:n { \driver_pdf_version_major: > #1}
||
(
- \int_compare_p:n { \driver_pdf_majorversion: = #1}
+ \int_compare_p:n { \driver_pdf_version_major: = #1}
&&
- \int_compare_p:n { \driver_pdf_minorversion: > #2 }
+ \int_compare_p:n { \driver_pdf_version_minor: > #2 }
)
}
{ \prg_return_true: }
@@ -318,6 +340,30 @@
%
% High-level startlink commands that uses the stored attributes:
% At first one with the \texttt{user} argument:
+% A link command that grabs the content as argument and inserts both
+% startlink and endlink directly (driver command is already in l3driver).
+% \begin{macrocode}
+%<*package>
+\cs_new_protected:Nn \pdf_link_user:nnn %#1 type (url, file etc, #2 action spec, #3 link text
+ {
+ \seq_use:cn { l__pdf_hook_startlink_#1_seq }{}
+ \mode_leave_vertical:
+ \driver_pdf_link_user:nnn
+ {
+ \prop_map_function:cN
+ { l__pdf_hook_startlink_#1_attr_prop }
+ \__pdf_get_key_value:nn
+ }
+ {
+ #2
+ }
+ {
+ #3
+ }
+ \seq_use:cn { l__pdf_hook_endlink_#1_seq }{}
+ }
+%</package>
+% \end{macrocode}
% \begin{macrocode}
%<*package>
\cs_new_protected:Nn \pdf_startlink_user:nn %#1 type, #2 action spec
diff --git a/test-pdfresources.tex b/test-pdfresources.tex
index b17f04d..1390cfe 100644
--- a/test-pdfresources.tex
+++ b/test-pdfresources.tex
@@ -5,12 +5,7 @@
\documentclass{article}
\usepackage{expl3}
-%very bad hack to input the dtx directly ....
-\def\documentclass#1\end#2{}
-
-\makeatletter\ExplSyntaxOn
-\input{pdfresources.dtx}
-\makeatother\ExplSyntaxOff
+\usepackage{pdfresources}
%don't compress pdf:
\ExplSyntaxOn
@@ -18,13 +13,45 @@
\driver_pdf_objects_disable:
\ExplSyntaxOff
\usepackage{xcolor}
-\usepackage[customdriver=hluatex-experimental]{hyperref}
-\tracingmacros=1
+\usepackage[customdriver=hluatex-experimental,ocgcolorlinks]{hyperref}
+
+%%\tracingmacros=1
\hypersetup{urlcolor=blue,linkbordercolor=blue,pdfborder={1 1 1},pdfprintpagerange=0}
-\makeatletter
+%%%\makeatletter
\hypupdateattribute
-\makeatletter\tracingmacros=1
+\makeatletter%\tracingmacros=1
+\textwidth=5cm
\begin{document}
+\ExplSyntaxOn
+\hook_put:nnnn
+ { pdf }
+ { startlink_url_attr }
+ { /C }
+ { [1~0~0] }
+
+\hook_put:nnnn
+ { pdf }
+ { startlink_url_attr }
+ { /Border }
+ { [1~1~1] }
+\driver_pdf_link_margin:n {1pt}
+xx\pdf_link_user:nnn {url}{/A<</Type/Action/S/URI/URI(www.blub.de)>>}{blbl\\blb\par blub}
+
+\par\bigskip
+xxx
+\driver_pdf_link_user:nnn
+ {/C~[1~0~0]
+ /Border [0.5~0.5~0.5]}
+ {/A<</Type/Action/S/URI/URI(www.blub.de)>>}
+ {long~text~text~text~text~text~text~text~text}
+
+
+\section{a}\label{a}
+\ref{a}
+\ExplSyntaxOff
+
+%\hyperlink{blblb}{yabc\\xye\\abc}
+\end{document}
\section{a}\label{a}
\ref{a}
\newpage
More information about the latex3-commits
mailing list