[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: getting rid of more \pdfref (fd8eb34)
Ulrike Fischer
fischer at troubleshooting-tex.de
Tue Apr 30 15:21:09 CEST 2019
Repository : https://github.com/latex3/pdfresources
On branch : testlinkstuff
Link : https://github.com/latex3/pdfresources/commit/fd8eb34d6c55d471736e20256842b439fa264836
>---------------------------------------------------------------
commit fd8eb34d6c55d471736e20256842b439fa264836
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Tue Apr 30 15:21:09 2019 +0200
getting rid of more \pdfref
>---------------------------------------------------------------
fd8eb34d6c55d471736e20256842b439fa264836
hluatex-experimental.def | 45 +++++++++++++++++++++++++--------------------
pdfresources.dtx | 16 +++++++++++++++-
test-pdfresources.tex | 35 ++++++++++++++++++++++++++++-------
3 files changed, 68 insertions(+), 28 deletions(-)
diff --git a/hluatex-experimental.def b/hluatex-experimental.def
index d6dd847..4e9d8eb 100644
--- a/hluatex-experimental.def
+++ b/hluatex-experimental.def
@@ -153,10 +153,10 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\protected\def\pdflastannot {\numexpr\pdffeedback lastannot\relax}
-\protected\def\pdflastlink {\numexpr\pdffeedback lastlink\relax}
+%\protected\def\pdflastlink {\numexpr\pdffeedback lastlink\relax}
\protected\def\pdflastobj {\numexpr\pdffeedback lastobj\relax}
-\protected\edef\pdflinkmargin {\pdfvariable linkmargin}
+%\protected\edef\pdflinkmargin {\pdfvariable linkmargin}
\protected\def\pdfliteral {\pdfextension literal}
\protected\def\pdfobj {\pdfextension obj }
@@ -166,7 +166,7 @@
\protected\edef\pdfpageresources {\pdfvariable pageresources}
\protected\edef\pdfpagesattr {\pdfvariable pagesattr}
-\protected\def\pdfrefobj {\pdfextension refobj }
+%\protected\def\pdfrefobj {\pdfextension refobj }
\protected\def\pdfstartlink {\pdfextension startlink }
\protected\def\pdfendlink {\pdfextension endlink\relax}
@@ -262,7 +262,7 @@
\Hy at temp@A\lastsavedboxresourceindex{form XObject}%
\Hy at temp@A\lastsavedimageresourceindex{image XObject}%
\Hy at temp@A\pdflastannot{annotation}%
- \Hy at temp@A\pdflastlink{link}%
+ \Hy at temp@A\driver_pdf_link_last_int:{link}%
\ifx\Hy at temp\ltx at empty
\int_compare:nNnTF { \Hy at pdfversion} = {10 }
{ %pdf 2.0, temporary solution
@@ -317,8 +317,9 @@
\ExplSyntaxOn
\ifHy at ocgcolorlinks
\pdf at ifdraftmode{}{
- \immediate\pdfobj{
- <<
+ \driver_pdf_object_new:nn { l__hyp_ocg_view_obj } { dict }
+ \driver_pdf_object_write:nn { l__hyp_ocg_view_obj }
+ {
/Type/OCG
/Name(View)
/Usage<<
@@ -329,9 +330,7 @@
/ViewState/ON
>>
>>
- >>
- }
- \edef\OBJ at OCG@view{\the\pdflastobj\c_space_tl 0\c_space_tl R}%
+ }
\immediate\pdfobj{
<<
/Type/OCG
@@ -349,7 +348,7 @@
\edef\OBJ at OCG@print{\the\pdflastobj\c_space_tl 0\c_space_tl R}
\immediate\pdfobj{
[
- \OBJ at OCG@view\c_space_tl\OBJ at OCG@print
+ \driver_pdf_object_ref:n { l__hyp_ocg_view_obj }\c_space_tl\OBJ at OCG@print
]
}
\edef\OBJ at OCGs{\the\pdflastobj\c_space_tl 0\c_space_tl R}
@@ -384,7 +383,7 @@
\pdfpageresources{
\the\pdfpageresources
/Properties<<
- /OCView\c_space_tl \OBJ at OCG@view
+ /OCView ~ \driver_pdf_object_ref:n { l__hyp_ocg_view_obj}
/OCPrint\c_space_tl \OBJ at OCG@print
>>
}
@@ -889,23 +888,26 @@
\let\HyField at AuxAddToFields\ltx at gobble
\let\HyField at AuxAddToCoFields\ltx at gobbletwo
\def\HyField at AfterAuxOpen{\Hy at AtBeginDocument}%
+
+\ExplSyntaxOn
+
\def\HyField at ABD@AuxAddToCoFields#1#2{%
- \begingroup
+ \group_begin:
\Hy at safe@activestrue
\let\ltx at secondoftwo\relax
\ifx\HyField at cofields\ltx at empty
\xdef\HyField at cofields{%
- \ltx at secondoftwo{#1}{ #2 0 R}%
- }%
+ \ltx at secondoftwo{#1}{ #2 ~ 0 ~ R}%
+ }
\else
\let\ltx at secondoftwo\relax
\def\HyField at AddCoField##1##2##3{%
\ifx##1\ltx at empty
- \ltx at secondoftwo{#1}{ #2 0 R}%
+ \ltx at secondoftwo{#1}{ #2 ~ 0 ~ R}%
\expandafter\ltx at gobble
\else
\ifnum\pdf at strcmp{##2}{#1}>\ltx at zero
- \ltx at secondoftwo{#1}{ #2 0 R}%
+ \ltx at secondoftwo{#1}{ #2 ~ 0 ~ R}%
\ltx at secondoftwo{##2}{##3}%
\expandafter\expandafter\expandafter\ltx at gobble
\else
@@ -919,8 +921,9 @@
\HyField at cofields\ltx at empty\ltx at empty\ltx at empty
}%
\fi
- \endgroup
+ \group_end:
}%
+
\Hy at AtBeginDocument{%
\if at filesw
\immediate\write\@mainaux{%
@@ -938,14 +941,14 @@
\HyField at afields
\space
\fi
- #1 0 R%
+ #1 ~ 0 ~ R%
}%
}%
\let\HyField at AuxAddToCoFields\HyField at ABD@AuxAddToCoFields
}%
\def\HyField at AddToFields{%
\expandafter\HyField@@AddToFields\expandafter{%
- \the\pdflastlink
+ \the\driver_pdf_link_last_int:
}%
\ifx\Fld at calculate@code\ltx at empty
\else
@@ -958,7 +961,7 @@
\string\HyField at AuxAddToCoFields{%
\Fld at calculate@sortkey
}{%
- \the\pdflastlink
+ \the\driver_pdf_link_last_int:
}%
}%
\fi
@@ -975,6 +978,8 @@
\fi
}%
}%
+
+\ExplSyntaxOff
\ExplSyntaxOn
\def\@Form[#1]
diff --git a/pdfresources.dtx b/pdfresources.dtx
index a0b555d..a71da8d 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -126,9 +126,16 @@
%<*package>
%some variants
\cs_generate_variant:Nn\driver_pdf_object_write:nn {nx}
-
+% version for link_last which gives an int. try to get rid of the necessity if possible
\sys_if_engine_pdftex:T
{
+ \cs_new:Npx \driver_pdf_link_last_int:
+ {
+ \cs_if_exist:NTF \tex_pdffeedback:D
+ { \tex_numexpr:D \exp_not:N \tex_pdffeedback:D lastlink \scan_stop: }
+ { \exp_not:N \tex_pdflastlink:D }
+ }
+
\cs_new_protected:Nn \driver_pdf_docview:nn %#1 page number, #2 e.g. /FitH
{
@@ -165,6 +172,13 @@
{
\pdfextension catalog { } openaction~goto~page #1 {#2}
}
+ % version for link_last which gives an int. try to get rid of the necessity if possible
+ \cs_new:Npx \driver_pdf_link_last_int:
+ {
+ \cs_if_exist:NTF \tex_pdffeedback:D
+ { \tex_numexpr:D \exp_not:N \tex_pdffeedback:D lastlink \scan_stop: }
+ { \exp_not:N \tex_pdflastlink:D }
+ }
\cs_new_protected:Npn \driver_pdf_catalog:n #1 %content, currently needed as hyperref has \Hy at PutCatalog
{
diff --git a/test-pdfresources.tex b/test-pdfresources.tex
index 747f67b..1b19da0 100644
--- a/test-pdfresources.tex
+++ b/test-pdfresources.tex
@@ -15,7 +15,7 @@
\ExplSyntaxOff
\usepackage{xcolor}
-\usepackage[customdriver=hluatex-experimental,pdfversion=2.0,pdftitle=X]{hyperref}
+\usepackage[customdriver=hluatex-experimental,pdfversion=2.0,pdftitle=X,ocgcolorlinks]{hyperref}
%%\tracingmacros=1
\hypersetup{urlbordercolor=blue,linkbordercolor=green,pdfborder={1 1 1},pdfprintpagerange=0}
@@ -29,14 +29,35 @@
\TextField{abc}
\TextField{cde}
abc%\end{document}
-
-\pdfextension obj reserveobjnum
-\the\pdflastobj
-
-\pdfextension obj reserveobjnum
-\the\pdflastobj
+%
+%\noindent
+%\TextField[name=hight,align=0]{Hight [cm]}
+%\\
+%
+%\TextField[name=weight,align=0]{Weight [kg]}
+%\\
+%
+%\noindent
+%\TextField[name=BMI, maxlen=4,align=0,readonly=true,
+% calculate={%
+% var f_hight = this.getField("hight");
+% var f_weight = this.getField("weight");
+% event.value = f_weight.value /((f_hight.value/100)*
+% (f_hight.value/100));
+% }]{BMI}
+
+%\pdfextension obj reserveobjnum
+%\the\pdflastobj
+%
+%\pdfextension obj reserveobjnum
+%\the\pdflastobj
\ExplSyntaxOn
+%\cs_show:N\driver_pdf_link_last_int:
+%
+%%\ifnum \driver_pdf_link_last_int: = 0 yes \fi
+%
+%\ifnum \driver_pdf_link_last_int: = 0 yes \fi
%\cs_show:N\driver_pdf_object_new:nn
More information about the latex3-commits
mailing list