[latex3-commits] [git/LaTeX3-latex3-latex3] master: Add the 'Adobe Reader fix' to driver code (6375a9d)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Apr 19 09:10:03 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/6375a9d4bcdb05846fbdd6c2de6a2a0cab20ff79

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

commit 6375a9d4bcdb05846fbdd6c2de6a2a0cab20ff79
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Apr 19 08:10:03 2019 +0100

    Add the 'Adobe Reader fix' to driver code
    
    One could argue that this belongs higher up, but
    it is likely we'll need to fiddle with OCGs later:
    that really does need to be done in the driver.
    
    Landscape pages and a few other effects still to look at.


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

6375a9d4bcdb05846fbdd6c2de6a2a0cab20ff79
 l3kernel/l3drivers-pdf.dtx              |   75 ++++++++++++++++++++++++++++---
 l3kernel/testfiles/m3expl001.luatex.tlg |    2 +
 l3kernel/testfiles/m3expl001.ptex.tlg   |    2 +
 l3kernel/testfiles/m3expl001.tlg        |    2 +
 l3kernel/testfiles/m3expl001.uptex.tlg  |    2 +
 l3kernel/testfiles/m3expl001.xetex.tlg  |    2 +
 l3kernel/testfiles/m3expl003.luatex.tlg |    2 +
 l3kernel/testfiles/m3expl003.ptex.tlg   |    2 +
 l3kernel/testfiles/m3expl003.tlg        |    2 +
 l3kernel/testfiles/m3expl003.uptex.tlg  |    2 +
 l3kernel/testfiles/m3expl003.xetex.tlg  |    2 +
 11 files changed, 90 insertions(+), 5 deletions(-)

diff --git a/l3kernel/l3drivers-pdf.dtx b/l3kernel/l3drivers-pdf.dtx
index bf6fb4d..a637de5 100644
--- a/l3kernel/l3drivers-pdf.dtx
+++ b/l3kernel/l3drivers-pdf.dtx
@@ -60,6 +60,22 @@
 %<@@=driver>
 %    \end{macrocode}
 %
+% \subsection{Shared code}
+%
+% A very small number of items that belong at the driver level but which
+% are common to all drivers.
+%
+% \begin{variable}{\c_@@_pdf_AR_fix_tl}
+%   Part of a fix for a bug in Adobe Reader: see
+%   \url{https://forums.adobe.com/message/5787612#5787612}. The workaround
+%   is taken from \pkg{pdfbase}: this \enquote{magic} dictionary entry has to
+%   be passed correctly to each driver.
+%    \begin{macrocode}
+\tl_const:Nn \c_@@_pdf_AR_fix_tl
+  { /Ff ~ 65537 /FT /Btn /Subtype /Widget }
+%    \end{macrocode}
+% \end{variable}
+%
 % \subsection{\texttt{dvips} driver}
 %
 %    \begin{macrocode}
@@ -641,17 +657,32 @@
 %    \end{macrocode}
 % \end{variable}
 %
-% \begin{macro}{\driver_pdf_annotation:nnnn}
+% \begin{macro}{\driver_pdf_annotation:nnnn, \@@_pdf_annotation:nnnn}
 % \begin{macro}{driver.llx, driver.lly, driver.urx, driver.ury}
 %   Annotations are objects, but we track them separately. Notably, they are
 %   not in the object data lists. Here, to get the co-ordinates of the
 %   annotation, we need to have the data collected at the PostScript level.
 %   That requires a bit of box trickery (effectively a \LaTeXe{} |picture|
 %   of zero size). Once the data is collected, use it to set up the annotation
-%   border.
+%   border. There is a split into two parts here to allow an easy way of
+%   applying the Adobe Reader fix.
 %    \begin{macrocode}
 \cs_new_protected:Npn \driver_pdf_annotation:nnnn #1#2#3#4
   {
+    \@@_pdf_annotation:nnnn {#1} {#2} {#3} {#4}
+    \int_gincr:N \g_@@_pdf_object_int
+    \int_gset_eq:NN \g_@@_pdf_annotation_int \g_@@_pdf_object_int
+    \@@_postscript:x
+      {
+          mark
+            /_objdef { driver.obj \int_use:N \g_@@_pdf_object_int }
+            driver.annotation.border ~
+            #4 ~
+            /ANN ~ pdfmark
+      }
+  }
+\cs_new_protected:Npn \@@_pdf_annotation:nnnn #1#2#3#4
+  {
     \box_move_down:nn {#3}
       { \hbox:n { \@@_postscript:n { driver.annotation.ll } } }
     \hbox:n {#4}
@@ -667,9 +698,10 @@
     \int_gset_eq:NN \g_@@_pdf_annotation_int \g_@@_pdf_object_int
     \@@_postscript:x
       {
-          mark /_objdef { driver.obj \int_use:N \g_@@_pdf_object_int }
-          driver.annotation.border ~
-          #4 ~
+        mark
+          /_objdef { driver.obj \int_use:N \g_@@_pdf_object_int }
+         driver.annotation.border ~
+          \c_@@_pdf_AR_fix_tl
           /ANN ~ pdfmark
       }
   }
@@ -758,6 +790,7 @@
   { \@@_pdf_link_begin:nnnw {#1} { } {#2} }
 \cs_new_protected:Npn \@@_pdf_link_begin:nnnw #1#2#3
   {
+    \@@_pdf_annotation:nnnn { 3pt } { 3pt } { 0pt } { }
     \@@_postscript:n
       { /driver.link.dict ( #1 ~ #2 ~ #3 ~ /Subtype /Link ) def }
     \int_gincr:N \g_@@_pdf_object_int
@@ -986,11 +1019,26 @@
 %
 % \subsubsection{Annotations}
 %
+% \begin{macro}{\@@_pdf_AR_fix:}
+%   The fix for the Adobe Reader bug: needed for generic annotations and links.
+%    \begin{macrocode}
+\cs_new_protected:Npx \@@_pdf_AR_fix:
+  {
+    \cs_if_exist:NTF \tex_pdfextension:D
+      { \tex_pdfextension:D annot ~ }
+      { \tex_pdfannot:D }
+      width  ~ 3pt ~ height ~ 3pt ~ depth ~ 0pt
+      { \c_@@_pdf_AR_fix_tl }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\driver_pdf_annotation:nnnn}
 %   Simply pass the raw data through, just dealing with evaluation of dimensions.
 %    \begin{macrocode}
 \cs_new_protected:Npx \driver_annotation:nnnn #1#2#3#4
   {
+    \@@_pdf_AR_fix:
     \cs_if_exist:NTF \tex_pdfextension:D
       { \tex_pdfextension:D annot ~ }
       { \tex_pdfannot:D }
@@ -1028,6 +1076,7 @@
   { \@@_pdf_link_begin:nnnw {#1} { user } {#2} }
 \cs_new_protected:Npx \@@_pdf_link_begin:nnnw #1#2#3
   {
+    \@@_pdf_AR_fix:
     \cs_if_exist:NTF \tex_pdfextension:D
       { \tex_pdfextension:D startlink ~ }
       { \tex_pdfstartlink:D }
@@ -1348,6 +1397,20 @@
 %
 % \subsubsection{Annotations}
 %
+% \begin{macro}{\@@_pdf_AR_fix:}
+%   The fix for the Adobe Reader bug: needed for generic annotations and links.
+%    \begin{macrocode}
+\cs_new_protected:Npx \@@_pdf_AR_fix:
+  {
+    \@@_pdf:n
+      {
+        ann ~ width ~ 3pt ~ height ~ 3pt ~ depth ~ 0pt
+        << \c_@@_pdf_AR_fix_tl >>
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{variable}{\g_@@_pdf_annotation_int}
 %   Needed as objects which are not annotations could be created.
 %    \begin{macrocode}
@@ -1361,6 +1424,7 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \driver_pdf_annotation:nnnn #1#2#3#4
   {
+    \@@_pdf_AR_fix:
     \int_gincr:N \g_@@_pdf_object_int
     \int_gset_eq:NN \g_@@_pdf_annotation_int \g_@@_pdf_object_int
     \@@_pdf:x
@@ -1387,6 +1451,7 @@
   { \@@_pdf_link_begin:nnnw {#1} { } {#2} }
 \cs_new_protected:Npn \@@_pdf_link_begin:nnnw #1#2#3
   {
+    \@@_pdf_AR_fix:
     \@@_pdf:n
       {
          bann
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 1d95609..ef3e627 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -6462,6 +6462,8 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \driver_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
 Defining \driver_pdf_link_begin_goto:nnw on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 8a19a18..508d8a0 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -6504,6 +6504,7 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \g__driver_pdf_object_int on line ...
@@ -6518,6 +6519,7 @@ Defining \__driver_pdf_object_write_dict:nn on line ..
 Defining \__driver_pdf_object_write_fstream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nnnn on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index d4ce4b0..72064eb 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -6803,6 +6803,8 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \driver_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
 Defining \driver_pdf_link_begin_goto:nnw on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 9d9564e..bd9ac08 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -6801,6 +6801,7 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \g__driver_pdf_object_int on line ...
@@ -6815,6 +6816,7 @@ Defining \__driver_pdf_object_write_dict:nn on line ..
 Defining \__driver_pdf_object_write_fstream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nnnn on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 6c3dfce..602bd16 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -6480,6 +6480,7 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \g__driver_pdf_object_int on line ...
@@ -6494,6 +6495,7 @@ Defining \__driver_pdf_object_write_dict:nn on line ..
 Defining \__driver_pdf_object_write_fstream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nnnn on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 1d95609..ef3e627 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -6462,6 +6462,8 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \driver_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
 Defining \driver_pdf_link_begin_goto:nnw on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 8a19a18..508d8a0 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -6504,6 +6504,7 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \g__driver_pdf_object_int on line ...
@@ -6518,6 +6519,7 @@ Defining \__driver_pdf_object_write_dict:nn on line ..
 Defining \__driver_pdf_object_write_fstream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nnnn on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index d4ce4b0..72064eb 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -6803,6 +6803,8 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \driver_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
 Defining \driver_pdf_link_begin_goto:nnw on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 9d9564e..bd9ac08 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -6801,6 +6801,7 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \g__driver_pdf_object_int on line ...
@@ -6815,6 +6816,7 @@ Defining \__driver_pdf_object_write_dict:nn on line ..
 Defining \__driver_pdf_object_write_fstream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nnnn on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 6c3dfce..602bd16 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -6480,6 +6480,7 @@ 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 \c__driver_pdf_AR_fix_tl on line ...
 Defining \__driver_pdf:n on line ...
 Defining \__driver_pdf:x on line ...
 Defining \g__driver_pdf_object_int on line ...
@@ -6494,6 +6495,7 @@ Defining \__driver_pdf_object_write_dict:nn on line ..
 Defining \__driver_pdf_object_write_fstream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nn on line ...
 Defining \__driver_pdf_object_write_stream:nnnn on line ...
+Defining \__driver_pdf_AR_fix: on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...





More information about the latex3-commits mailing list