[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: pageresource text (b039670)

Ulrike Fischer fischer at troubleshooting-tex.de
Sun May 5 21:54:12 CEST 2019


Repository : https://github.com/latex3/pdfresources
On branch  : testlinkstuff
Link       : https://github.com/latex3/pdfresources/commit/b0396705ec093f51cd622ebc6e08b5003c919581

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

commit b0396705ec093f51cd622ebc6e08b5003c919581
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sun May 5 21:54:12 2019 +0200

    pageresource text


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

b0396705ec093f51cd622ebc6e08b5003c919581
 hluatex-experimental.def |  125 ++++++++++++++++-------------
 pageresources.tex        |  197 ++++++++++++++++++++++++++++++++++++++++++++++
 pdfresources.dtx         |    2 +-
 test-pdfresources.tex    |    3 +-
 4 files changed, 269 insertions(+), 58 deletions(-)

diff --git a/hluatex-experimental.def b/hluatex-experimental.def
index 649e5d3..8dee08d 100644
--- a/hluatex-experimental.def
+++ b/hluatex-experimental.def
@@ -30,6 +30,12 @@
   {hyp}
   {pdfa-no-push-button}
   {PDF/A:~Push~button~with~JavaScript~is~prohibited}
+
+\msg_new:nnn
+  {hyp}
+  {pdfa-no-reset-button}
+  {PDF/A:~Reset~action~is~prohibited}
+
 %% I require the bookmark package to get rid of some of the bookmarks code.
 \AtEndOfPackage{% so that we are later than KOMA ...
 \AtBeginDocument
@@ -161,7 +167,7 @@
 %\protected\def\pdflastannot      {\numexpr\pdffeedback lastannot\relax}
 %\protected\def\pdflastobj        {\numexpr\pdffeedback lastobj\relax}
 
-\protected\def\pdfliteral        {\pdfextension literal}
+%\protected\def\pdfliteral        {\pdfextension literal}
 
 \protected\edef\pdfpageattr            {\pdfvariable pageattr}
 
@@ -169,8 +175,8 @@
 \protected\edef\pdfpagesattr           {\pdfvariable pagesattr}
 
 
-\protected\def\pdfstartlink      {\pdfextension startlink }
-\protected\def\pdfendlink        {\pdfextension endlink\relax}
+%\protected\def\pdfstartlink      {\pdfextension startlink }
+%\protected\def\pdfendlink        {\pdfextension endlink\relax}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -388,7 +394,7 @@
   }
   \Hy at AtBeginDocument{
     \def\Hy at colorlink#1{
-      \begingroup
+      \group_begin:
         \ifHy at ocgcolorlinks
           \def\Hy at ocgcolor{#1}
           \setbox0=\hbox\bgroup\color at begingroup
@@ -401,18 +407,20 @@
         \color at endgroup\egroup
         \mbox{
           %this uses a named object, we really need to sort this ...
-          \pdfliteral~page{/OC/OCPrint~BDC}
+          \driver_pdf_bdc:nn {/OC}{/OCPrint}
+          %\pdfliteral~page{/OC/OCPrint~BDC}
           \rlap{\copy0}
           \driver_pdf_emc:
-          \pdfliteral~page{/OC/OCView~BDC}
-          \begingroup
+          %\pdfliteral~page{/OC/OCView~BDC}
+          \driver_pdf_bdc:nn {/OC}{/OCView}
+          \group_begin:
             \expandafter\HyColor at UseColor\Hy at ocgcolor
             \box0~
-          \endgroup
+          \group_end:
           \driver_pdf_emc:
         }
       \fi
-      \endgroup
+      \group_end:
     }
   }
  }
@@ -505,11 +513,11 @@
   \pdf_link_end:n { #1 }
 }
 
-\def\close at pdflink{%
-  \Hy at endcolorlink
-  \Hy at VerboseLinkStop
-  \pdfendlink
-}
+%\def\close at pdflink{%
+%  \Hy at endcolorlink
+%  \Hy at VerboseLinkStop
+%  \pdfendlink
+%}
 \ExplSyntaxOff
 \def\hyper at anchor#1{%
   \new at pdflink{#1}\anchor at spot\pdf at endanchor
@@ -1206,9 +1214,8 @@
     \HyAnn at AbsPageLabel
     \Hy at escapeform\PDFForm at Radio
     \pdf_link_user:nnn
-       {widget} %perhaps we need more types??
-     %\pdfstartlink user
-       {
+      {widget} %perhaps we need more types??
+      {
         \PDFForm at Radio
         /AP
          <<
@@ -1217,9 +1224,8 @@
           /\@currValue\c_space_tl \DingObject
           >>
          >>
-       }
-     {  \MakeRadioField{\Fld at width}{\Fld at height} }
-     %\pdfendlink
+      }
+      {  \MakeRadioField{\Fld at width}{\Fld at height} }
      \int_compare:nNnT { \Fld at listcount} = { 1 }
       { \HyField at AddToFields }
     \c_space_tl % deliberate space between radio buttons
@@ -1303,56 +1309,63 @@
   \group_end:
  }
 
-\ExplSyntaxOff
-
-\def\@Reset[#1]#2{%
-  \def\Fld at width{\DefaultWidthofReset}%
-  \def\Fld at height{\DefaultHeightofReset}%
-  \begingroup
-    \expandafter\HyField at SetKeys\expandafter{%
-      \DefaultOptionsofReset,#1%
-    }%
-    \leavevmode
-    \ifHy at pdfa
-      \Hy at Error{%
-        PDF/A: Reset action is prohibited%
-      }\@ehc
-      \MakeButtonField{#2}%
-    \else
+\def\@Reset[#1]#2
+ {
+  \def\Fld at width{\DefaultWidthofReset}
+  \def\Fld at height{\DefaultHeightofReset}
+  \group_begin:
+    \exp_args:No\HyField at SetKeys
+     {
+       \DefaultOptionsofReset,#1
+     }
+    \mode_leave_vertical:
+    \bool_if:NTF \l__hyp_pdfa_bool
+     {
+      \msg_error:nn { hyp }{ pdfa-no-reset-button }
+      \MakeButtonField{#2}
+     }
+     {
       \HyField at FlagsPushButton
       \ifFld at hidden\def\Fld at width{1sp}\fi
       \HyAnn at AbsPageLabel
       \Hy at escapeform\PDFForm at Reset
-      \pdfstartlink user {\PDFForm at Reset}\relax
-      \MakeButtonField{#2}%
-      \pdfendlink
+      \pdf_link_user:nnn
+       {widget} %perhaps more types needed
+       {\PDFForm at Reset}
+       {\MakeButtonField{#2}}
       \HyField at AddToFields
-    \fi
-  \endgroup
+     }
+  \group_end:
 }
-\def\@CheckBox[#1]#2{% parameters, label
-  \def\Fld at name{#2}%
-  \def\Fld at default{0}%
-  \begingroup
-    \def\Fld at width{\DefaultWidthofCheckBox}%
-    \def\Fld at height{\DefaultHeightofCheckBox}%
-    \expandafter\HyField at SetKeys\expandafter{%
-      \DefaultOptionsofCheckBox,#1%
-    }%
+
+\def\@CheckBox[#1]#2
+ {% parameters, label
+  \def\Fld at name{#2}
+  \def\Fld at default{0}
+  \group_begin:
+    \def\Fld at width{\DefaultWidthofCheckBox}
+    \def\Fld at height{\DefaultHeightofCheckBox}
+    \exp_args:No\HyField at SetKeys
+     {
+      \DefaultOptionsofCheckBox,#1
+     }
     \PDFForm at Name
     \HyField at FlagsCheckBox
     \ifFld at hidden\def\Fld at width{1sp}\fi
     \LayoutCheckField{#2}{%
-      \leavevmode
+      \mode_leave_vertical:
       \HyAnn at AbsPageLabel
       \Hy at escapeform\PDFForm at Check
-      \pdfstartlink user {\PDFForm at Check}\relax
-      \MakeCheckField{\Fld at width}{\Fld at height}%
-      \pdfendlink
+      \pdf_link_user:nnn
+       {widget} %perhaps we need more types
+       {\PDFForm at Check}
+       {\MakeCheckField{\Fld at width}{\Fld at height}}
       \HyField at AddToFields
-    }%
-  \endgroup
+    }
+  \group_end:
 }
+\ExplSyntaxOff
+
 %hm. Should a luatex driver use type1 fonts in fields????
 \ExplSyntaxOn
 \def\Hy at FormObjects{%
diff --git a/pageresources.tex b/pageresources.tex
new file mode 100644
index 0000000..4da2f49
--- /dev/null
+++ b/pageresources.tex
@@ -0,0 +1,197 @@
+% !Mode:: "TeX:DE:UTF-8:Main"
+%\input{regression-test}
+\RequirePackage{pdfresources}
+%\documentsetup{pdfversion=2.0}
+\ExplSyntaxOn
+\driver_pdf_compresslevel:n {0}
+\driver_pdf_objects_disable:
+\ExplSyntaxOff
+\documentclass{article}
+\usepackage[english]{babel}
+\usepackage[autostyle]{csquotes}
+%\RequirePackage[customdriver=hluatex-experimental]{hyperref}
+\begin{document}
+
+\title{Sorting page resources}
+\maketitle
+
+\section{pdfpagesattr}
+\begin{itemize}
+\item token register, is added to the root object when the pdf is finished 
+
+\item non-additive: A new call overwrites the content of the register.
+\end{itemize}
+
+\begin{verbatim}
+\pdfpagesattr{/WWWWW (blab)}
+<<
+/Type /Pages
+/Count 1
+/Kids [2 0 R]
+/WWWWW (blab)
+>>
+\end{verbatim}
+
+\subsection{Uses}
+\begin{description}
+\item[zref-pageattr]: get current content
+\item[hyperref: Cropbox] \verb+/CropBox[\@pdfpagescrop]+, takes care of existing content
+\item[llncsconf: Cropbox]    overwrites existing content
+\item[authorarchive: Cropbox] overwrites existing content
+\item[pdfx: various box sizes in pdf/x standard]  overwrites existing content
+\begin{verbatim}
+  \edef\next{\endgroup\pdfpagesattr{%
+    /MediaBox[0 0 \pdfx at mwidth\space \pdfx at mheight]^^J
+%%    /ArtBox[0 0 \pdfx at mwidth\space \pdfx at mheight]^^J
+    /BleedBox[0 0 \pdfx at mwidth\space \pdfx at mheight]^^J
+    /CropBox[0 0 \pdfx at mwidth\space \pdfx at mheight]^^J
+    /TrimBox[25 20 \pdfx at twidth\space \pdfx at theight]}
+  }\next
+\end{verbatim}
+and then copies to the page attribute if these are empty (why?): 
+\begin{verbatim}
+ \EveryShipout{%
+    \expandafter\ifx\expandafter\relax\the\pdfpageattr\relax
+     \immediate\pdfpageattr\expandafter{\the\pdfpagesattr}%
+    \fi }%
+\end{verbatim}    
+\end{description}
+
+\subsection{Discussion}
+
+The values added here are simple arrays. The data structure is easy: One needs a property, a command to add and one to remove a key. The main open problem is when to move the content of the property to \verb`\pdfpagesattr` and how to force packages to use the property. Can one redefine \verb+\pdfpageattr+ so that \verb+\the\pdfpageattr+ doesn't gives bad errors?
+ 
+
+\section{pdfpageattr}
+\begin{itemize}
+\item token register, is added to the current page at shipout
+\item non-additive: A new call overwrites the content of the register.
+\item Entries (emphasized if used/set by packages): 
+   \begin{enumerate}
+    \item Resources (dict, see below),
+    \item \emph{MediaBox}, \emph{CropBox}, \emph{Bleedbox}, \emph{Trimbox}, \emph{Artbox} (rectangle array), 
+    \item \emph{Rotate} (integer),
+    \item \emph{Dur} (number),
+    \item \emph{Trans} (dict), 
+    \item \emph{AA} (dict, \enquote{additional actions}), 
+    \item \emph{StructParents} (integer), 
+    \item \emph{Tabs} (name, possible values are /R, /C, /S),   
+    \item BoxColorInfo (dict), 
+    \item Contents (stream or array, automatic),  
+    \item Group (dict), 
+    \item Thumb (stream), 
+    \item B (array),  
+    \item Annots (array, automatic), 
+    \item Metadata (stream), 
+    \item PieceInfo (dict), 
+    \item ID (byte string), 
+    \item PZ (number), 
+    \item SeparationInfo (dict),  
+    \item TemplateInstantiated (name),
+    \item  PresSteps (dict), 
+    \item UserUnit (number), 
+    \item VP (dict).
+    \end{enumerate}
+   \end{itemize}
+\begin{verbatim}
+\pdfpageattr{/XXXXXXXX (blub)}
+<<
+/Type /Page
+/Contents 3 0 R
+/Resources 1 0 R
+/MediaBox [0 0 595.276 841.89]
+/XXXXXXXX (blub)
+/Parent 9 0 R
+>>
+\end{verbatim}
+
+\subsection{Uses}
+\begin{description}
+  \item[aastex62.cls: Rotate] overwrites existing content
+  \item[beamer/multimedia: AA] \verb+ /AA << \mm at pdfpageadditionalaction\space >>+, uses hyperref code to add/remove entries.
+  \item[fancytoolstips: AA] \verb+/AA << /O << /S /JavaScript /JS (    \fancytooltips at pdfpageattrJS) >>  >>+, seems not to care about other packages.
+      
+  \item[gentombow: Bleedbox,Trimbox] seems not to care about other packages. 
+  \item[lscape: Rotate] seems not to care about other packages. 
+  \item[hyperref: Trans] \verb+/Trans << /S /\@pdfpagetransition\space >>+, has code to remove an existing /Trans value (if the dict is not an indirect object), takes care of existing content of the register.
+      
+  \item[hyperref: Dur] \verb+/Dur \@pdfpageduration\space+, see Trans.   
+  \item[hyperref: Hid] (obsolete page object) 
+  \item[jmlrbook.cls: MediaBox,Bleedbox,Trimbox] seems not to care about other packages. 
+  \item[pdflscape: Rotate] has code to remove an existing Rotate entry, takes care of existing content of the register.
+  \item[zref-pageattr:] Retrieve and store content.
+  \item[pdfslide (old): Trans]  seems not to care about other packages. 
+  \item[pdfx] See above at pdfpagesattr.
+  \item[tagpdf: StructParents, Tabs] (in tree code), avoids duplicates and takes care of existing content.
+\end{description}
+
+\subsection{Discussion}
+
+Most values are simple and can be handled similar to pdfpagesattr. The content of Trans can be a rather complicated dict, but only one transition per page makes sense, so it is ok if one package \enquote{wins}. It is theoretically possible that the AA entry should combine content from two sources (e.g. two javascript commands) but imho it should be then the task of the packages/the users to coordinate this.
+
+It must be decided when to copy the property into pdfpageattr. Atbeginshipout?
+
+\section{pdfpageresources}
+\begin{itemize}
+\item token register, is added to the Resources dictionary of all \emph{following} pages. 
+\item non-additive: A new call overwrites the content of the register.
+\item Entries:
+ \begin{enumerate}
+ \item \emph{ExtGState} (dict) 
+ \item \emph{ColorSpace} (dict)
+ \item \emph{Pattern} (dict)
+ \item \emph{Shading} (dict)
+ \item \emph{Properties} (dict) (maps names to objects for BDC-dictionaries)
+ \item Font (dict)
+ \item XObject (dict)
+ \item ProcSet (array) (obsolete)
+ \end{enumerate}
+  
+\end{itemize}
+\begin{verbatim}
+\pdfpageresources{/BBBBB (blub)}
+11 0 obj
+<<
+/Type /Page
+/Contents 12 0 R
+/Resources 10 0 R
+/MediaBox [0 0 595.276 841.89]
+/Parent 9 0 R
+>>
+endobj
+
+10 0 obj
+<<
+/BBBBB (blub)
+/Font << /F26 4 0 R /F14 5 0 R /F8 6 0 R /F31 13 0 R /F29 7 0 R >>
+/ProcSet [ /PDF /Text ]
+>>
+endobj
+\end{verbatim}
+
+\subsection{Uses}
+\begin{description}
+  \item[ocg] old sty, only pdftex. Add something to Properties, takes care of the rest of the resources but not of the current content of Properties.
+  \item[colorspace] Add entries to the Colorspace dict. Seems to expect that color are defined in the preamble or the first page. Unclear if it still clashes with pgf, see https://tex.stackexchange.com/a/405166/2388.
+  \item[hyperref] adds /OCView and /OCPrint to Properties, takes care of other content of pdfpageresources, but not of the content of Properties.
+  \item[pdfbase] adds content to Properties, takes care of other content of pdfpageresources, but imho not of the content of Properties. Will probably have a problem if the value of Properties is an indirect object.
+  \item[transparent] adds content to ExtGState \verb+/ExtGState<</TRP1<</ca 1/CA 1>>>>+. Tries to be compatible with pgf. 
+  \item[ocg-p] similar to ocg
+  \item[pdfpagediff] \verb+\edef\next{\pdfpageresources={/Properties \layersnames}}+
+  \item[sesamanuel.cls] \verb+/ExtGState \@extgs\space 0 R +, saves rest of resources.
+  \item[spotcolor] (old) \verb+/ColorSpace<<#1>>+, saves rest of resources. 
+  \item[storebox] copies pageresources to xform resources.    
+  \item[zwpagelayout] \verb+/ExtGState \@extgs\space 0 R+, saves rest of resources.
+  \item[pgf] Reserves objects for (at least) ExtGState, ColorSpace and Pattern, Shading seems to be used directly. 
+\end{description}
+
+\subsection{Discussion}
+Every of the five dictionaries ExtGState, ColorSpace, Pattern, Shading, Properties can receive values from more than one package and must combine them. So every of this entries needs its own properties and commands to add to the property. Packages can avoid duplicate keys by suitable name spaces. 
+
+It must be decided when to write the properties to pdfpageresources.
+
+\section{pdfcatalog}
+
+yet missing
+\end{document}
+
diff --git a/pdfresources.dtx b/pdfresources.dtx
index 2706985..f03cba5 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -144,7 +144,7 @@
 
 % this needs refinement, probably is should create named objects and add
 % them to the properties, see discussion
-%
+% https://chat.stackexchange.com/transcript/message/49970158#49970158
 \cs_new_protected:Npx \driver_pdf_bdc:nn #1 #2
   {
     \cs_if_exist:NTF \tex_pdfextension:D
diff --git a/test-pdfresources.tex b/test-pdfresources.tex
index 9b6571d..49764d1 100644
--- a/test-pdfresources.tex
+++ b/test-pdfresources.tex
@@ -23,7 +23,7 @@
             pdfversion=1.7,
            % pdfstartpage=3,
            % pdfstartview=
-           pdfview=FitV,pdfa
+           pdfview=FitV,
             ]{hyperref}
 
 
@@ -63,6 +63,7 @@
   backgroundcolor=red % why doesn't this work ?
 ]{\textcolor{blue}{Add an item}}
 
+\CheckBox{checkbox}
 
 \TextField{abc}
 \TextField{cde}





More information about the latex3-commits mailing list