[latex3-commits] [git/LaTeX3-latex3-latex3] master: Start on PDF link support (2f308c7)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Apr 9 22:33:23 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/2f308c73999547b6e7f020f1e7524f83d0b29788

>---------------------------------------------------------------

commit 2f308c73999547b6e7f020f1e7524f83d0b29788
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Apr 9 21:33:23 2019 +0100

    Start on PDF link support


>---------------------------------------------------------------

2f308c73999547b6e7f020f1e7524f83d0b29788
 l3kernel/l3drivers-pdf.dtx              |   84 ++++++++++++++++++++++++++++---
 l3kernel/l3drivers.dtx                  |   13 +++++
 l3kernel/testfiles/m3expl001.luatex.tlg |    4 ++
 l3kernel/testfiles/m3expl001.ptex.tlg   |    6 +++
 l3kernel/testfiles/m3expl001.tlg        |    4 ++
 l3kernel/testfiles/m3expl001.uptex.tlg  |    6 +++
 l3kernel/testfiles/m3expl001.xetex.tlg  |    6 +++
 l3kernel/testfiles/m3expl003.luatex.tlg |    4 ++
 l3kernel/testfiles/m3expl003.ptex.tlg   |    6 +++
 l3kernel/testfiles/m3expl003.tlg        |    4 ++
 l3kernel/testfiles/m3expl003.uptex.tlg  |    6 +++
 l3kernel/testfiles/m3expl003.xetex.tlg  |    6 +++
 12 files changed, 143 insertions(+), 6 deletions(-)

diff --git a/l3kernel/l3drivers-pdf.dtx b/l3kernel/l3drivers-pdf.dtx
index 28cfa67..cac7884 100644
--- a/l3kernel/l3drivers-pdf.dtx
+++ b/l3kernel/l3drivers-pdf.dtx
@@ -189,6 +189,39 @@
 %
 % \subsubsection{Annotations}
 %
+% \begin{macro}{\driver_link_begin_goto:nn, \driver_link_begin_user:nn}
+% \begin{macro}{\@@_link_begin:nnn}
+%   Links are all created using the same internals.
+%    \begin{macrocode}
+\cs_new_protected:Npn \driver_link_begin_goto:nn #1#2
+  { \@@_link_begin:nnn {#1} { goto~name } {#2} }
+\cs_new_protected:Npn \driver_link_begin_user:nn #1#2
+  { \@@_link_begin:nnn {#1} { user } {#2} }
+\cs_new_protected:Npx \@@_link_begin:nnn #1#2#3
+  {
+    \cs_if_exist:NTF \tex_pdfextension:D
+      { \tex_pdfextension:D startlink ~ }
+      { \tex_pdfstartlink:D }
+      attr {#1}
+      \exp_not:N \tl_if_blank:nF {#2}
+        { ~ #2 {#3} }
+  }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\driver_link_end:}
+%   Ending a link is easy.
+%    \begin{macrocode}
+\cs_new_protected:Npx \driver_link_end:
+  {
+    \cs_if_exist:NTF \tex_pdfextension:D
+      { \tex_pdfextension:D endlink }
+      { \tex_pdfendlink:D }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsubsection{Objects}
 %
 % \begin{variable}{\g_@@_pdf_object_prop}
@@ -310,8 +343,47 @@
 %<*dvipdfmx|xdvipdfmx>
 %    \end{macrocode}
 %
+% \begin{macro}{\@@_pdf:n, \@@_pdf:x}
+%   A generic function for the driver PDF specials: used where we can.
+%    \begin{macrocode}
+\cs_new_protected:Npx \@@_pdf:n #1
+  { \@@_literal:n { pdf: #1 } }
+\cs_generate_variant:Nn \@@_pdf:n { x }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsubsection{Annotations}
 %
+% \begin{macro}{\driver_link_begin_goto:nn, \driver_link_begin_user:nn}
+% \begin{macro}{\@@_link_begin:nnn}
+%    \begin{macrocode}
+\cs_new_protected:Npn \driver_link_begin_goto:nn #1#2
+  { \@@_pdf_startlink:nnn {#1} { /GoTo } {#2} }
+\cs_new_protected:Npn \driver_link_begin_user:nn #1#2
+  { \@@_pdf_startlink:nnn {#1} { } {#2} }
+\cs_new_protected:Npn \@@_link_begin:nnn #1#2#3
+  {
+    \@@_pdf:n
+      {
+         bann
+         <<
+           /Type /Annot
+           /Subtype /Link
+           #1 ~ #2 ~ #3
+         >>
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\driver_link_end:}
+%    \begin{macrocode}
+\cs_new_protected:Npx \driver_link_end:
+  { \@@_pdf:n { eann } }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsubsection{Objects}
 %
 % \begin{variable}{\g_@@_pdf_object_int, \g_@@_pdf_object_prop}
@@ -362,17 +434,17 @@
   { \use:c { @@_pdf_object_write_ #1 :nn } {#2} {#3} }
 \cs_new_protected:Npn \@@_pdf_object_write_array:nn #1#2
   {
-    \@@_literal:x
+    \@@_pdf:x
       {
-        pdf:obj ~ \driver_pdf_object_ref:n {#1} ~
+        obj ~ \driver_pdf_object_ref:n {#1} ~
           [ ~ \exp_not:n {#2} ~ ]
       }
   }
 \cs_new_protected:Npn \@@_pdf_object_write_dict:nn #1#2
   {
-    \@@_literal:x
+    \@@_pdf:x
       {
-        pdf:obj ~ \driver_pdf_object_ref:n {#1} ~
+        obj ~ \driver_pdf_object_ref:n {#1} ~
           << ~ \exp_not:n {#2} ~ >>
       }
   }
@@ -382,9 +454,9 @@
   { \@@_pdf_object_write_stream:nnnn { } {#1} #2 }
 \cs_new_protected:Npn \@@_pdf_object_write_stream:nnnn #1#2#3#4
   {
-    \@@_literal:x
+    \@@_pdf:x
       {
-        pdf: #1 stream ~ \driver_pdf_object_ref:n {#2} ~
+        #1 stream ~ \driver_pdf_object_ref:n {#2} ~
           ( \exp_not:n {#4} ) ~ << \exp_not:n {#3} >>
         
       }
diff --git a/l3kernel/l3drivers.dtx b/l3kernel/l3drivers.dtx
index 634505a..fef4c15 100644
--- a/l3kernel/l3drivers.dtx
+++ b/l3kernel/l3drivers.dtx
@@ -471,6 +471,19 @@
 % are generated by \texttt{dvips}: this depends on being able to pass
 % information through correctly.
 %
+% \subsection{PDF Annotations}
+%
+% \begin{function}[added = 2019-04-09]
+%   {\driver_link_begin_goto:nn, \driver_link_begin_user:nn, \driver_link_end:}
+%   \begin{syntax}
+%     \cs{driver_link_begin_user:nn} \Arg{} \Arg{}
+%     \meta{content}
+%     \cs{driver_link_end:}
+%   \end{syntax}
+%   Declares \meta{name} as a PDF object. The \texttt{type} should be one of
+%   |array| or |dict|, |fstream| or |stream|.
+% \end{function}
+%
 % \subsection{PDF Objects}
 %
 % Objects are used to provide a range of data structures in a PDF. At the
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 66480b7..2d440dd 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -6462,6 +6462,10 @@ Defining \__driver_image_getbb_auxii:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_prop on line ...
 Defining \driver_pdf_object_new:nn on line ...
 Defining \driver_pdf_object_ref:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 5277a13..d3f9b29 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -6504,6 +6504,12 @@ Defining \__driver_image_include_auxi:nn on line ...
 Defining \__driver_image_include_auxii:nnn on line ...
 Defining \__driver_image_include_auxii:xnn on line ...
 Defining \__driver_image_include_auxiii:nnn on line ...
+Defining \__driver_pdf:n on line ...
+Defining \__driver_pdf:x on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_int on line ...
 \g__driver_pdf_object_int=\count...
 Defining \g__driver_pdf_object_prop on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 8173e35..a0746c1 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -6803,6 +6803,10 @@ Defining \__driver_image_getbb_auxii:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_prop on line ...
 Defining \driver_pdf_object_new:nn on line ...
 Defining \driver_pdf_object_ref:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index b156ac7..925b311 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -6801,6 +6801,12 @@ Defining \__driver_image_include_auxi:nn on line ...
 Defining \__driver_image_include_auxii:nnn on line ...
 Defining \__driver_image_include_auxii:xnn on line ...
 Defining \__driver_image_include_auxiii:nnn on line ...
+Defining \__driver_pdf:n on line ...
+Defining \__driver_pdf:x on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_int on line ...
 \g__driver_pdf_object_int=\count...
 Defining \g__driver_pdf_object_prop on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 71356c1..10f2ff0 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -6480,6 +6480,12 @@ Defining \__driver_image_getbb_auxv:nNnn on line ...
 Defining \__driver_image_getbb_auxvi:nNnn on line ...
 Defining \__driver_image_getbb_pagebox:w on line ...
 Defining \__driver_image_include_pdf:n on line ...
+Defining \__driver_pdf:n on line ...
+Defining \__driver_pdf:x on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_int on line ...
 \g__driver_pdf_object_int=\count...
 Defining \g__driver_pdf_object_prop on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 66480b7..2d440dd 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -6462,6 +6462,10 @@ Defining \__driver_image_getbb_auxii:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_prop on line ...
 Defining \driver_pdf_object_new:nn on line ...
 Defining \driver_pdf_object_ref:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 5277a13..d3f9b29 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -6504,6 +6504,12 @@ Defining \__driver_image_include_auxi:nn on line ...
 Defining \__driver_image_include_auxii:nnn on line ...
 Defining \__driver_image_include_auxii:xnn on line ...
 Defining \__driver_image_include_auxiii:nnn on line ...
+Defining \__driver_pdf:n on line ...
+Defining \__driver_pdf:x on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_int on line ...
 \g__driver_pdf_object_int=\count...
 Defining \g__driver_pdf_object_prop on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 8173e35..a0746c1 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -6803,6 +6803,10 @@ Defining \__driver_image_getbb_auxii:n on line ...
 Defining \__driver_image_include_jpg:n on line ...
 Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_prop on line ...
 Defining \driver_pdf_object_new:nn on line ...
 Defining \driver_pdf_object_ref:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index b156ac7..925b311 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -6801,6 +6801,12 @@ Defining \__driver_image_include_auxi:nn on line ...
 Defining \__driver_image_include_auxii:nnn on line ...
 Defining \__driver_image_include_auxii:xnn on line ...
 Defining \__driver_image_include_auxiii:nnn on line ...
+Defining \__driver_pdf:n on line ...
+Defining \__driver_pdf:x on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_int on line ...
 \g__driver_pdf_object_int=\count...
 Defining \g__driver_pdf_object_prop on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 71356c1..10f2ff0 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -6480,6 +6480,12 @@ Defining \__driver_image_getbb_auxv:nNnn on line ...
 Defining \__driver_image_getbb_auxvi:nNnn on line ...
 Defining \__driver_image_getbb_pagebox:w on line ...
 Defining \__driver_image_include_pdf:n on line ...
+Defining \__driver_pdf:n on line ...
+Defining \__driver_pdf:x on line ...
+Defining \driver_link_begin_goto:nn on line ...
+Defining \driver_link_begin_user:nn on line ...
+Defining \__driver_link_begin:nnn on line ...
+Defining \driver_link_end: on line ...
 Defining \g__driver_pdf_object_int on line ...
 \g__driver_pdf_object_int=\count...
 Defining \g__driver_pdf_object_prop on line ...





More information about the latex3-commits mailing list