diff options
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf-tree.dtx')
-rw-r--r-- | macros/latex/contrib/tagpdf/tagpdf-tree.dtx | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf-tree.dtx b/macros/latex/contrib/tagpdf/tagpdf-tree.dtx index ef7bcd3f1a..36d9e74cbf 100644 --- a/macros/latex/contrib/tagpdf/tagpdf-tree.dtx +++ b/macros/latex/contrib/tagpdf/tagpdf-tree.dtx @@ -47,13 +47,13 @@ % }^^A % } % -% \date{Version 0.98w, released 2024-02-22} +% \date{Version 0.98x, released 2024-02-29} % \maketitle % \begin{implementation} % \begin{macrocode} %<@@=tag> %<*header> -\ProvidesExplPackage {tagpdf-tree-code} {2024-02-22} {0.98w} +\ProvidesExplPackage {tagpdf-tree-code} {2024-02-29} {0.98x} {part of tagpdf - code related to writing trees and dictionaries to the pdf} %</header> % \end{macrocode} @@ -96,8 +96,10 @@ % \end{macrocode} % \end{macro} % -% \subsection{Catalog: MarkInfo and StructTreeRoot} +% \subsection{Catalog: MarkInfo and StructTreeRoot and OpenAction} % The StructTreeRoot and the MarkInfo entry must be added to the catalog. +% If there is an OpenAction entry we must update it, +% so that it contains also a structure destination. % We do it late so that we can win, but before the pdfmanagement hook. % \begin{macro}{@@/struct/0} % This is the object for the root object, the StructTreeRoot @@ -105,6 +107,67 @@ \pdf_object_new:n { @@/struct/0 } % \end{macrocode} % \end{macro} +% +% \begin{variable}{\g_@@_tree_openaction_struct_tl} +% We need a variable that indicates which structure is wanted in the OpenAction. By default we use +% 1 (the Document structure). +% \begin{macrocode} +\tl_new:N \g_@@_tree_openaction_struct_tl +\tl_gset:Nn \g_@@_tree_openaction_struct_tl {1} +% \end{macrocode} +% \end{variable} +% +% \begin{macro}{viewer/startpage (setup-key)} +% We also need an option to setup the start structure. So we setup a key +% which sets the variable to the current structure. This still requires +% hyperref to do most of the job, this should perhaps be changed. +% \begin{macrocode} +\keys_define:nn { @@ / setup } + { + viewer/startstructure .code:n = + { + \tl_gset:Ne \g_@@_tree_openaction_struct_tl {#1} + } + ,viewer/startstructure .default:n = { \int_use:N \c@g_@@_struct_abs_int } + } +% \end{macrocode} +% \end{macro} +% The OpenAction should only be updated if it is there. So we inspect the +% Catalog-prop: +% \begin{macrocode} +\cs_new_protected:Npn \@@_tree_update_openaction: + { + \prop_get:cnNT + { \__kernel_pdfdict_name:n { g__pdf_Core/Catalog } } + {OpenAction} + \l_@@_tmpa_tl + { +% \end{macrocode} +% we only do something if the OpenAction is an array (as set by hyperref) +% in other cases we hope that the author knows what they did. +% \begin{macrocode} + \tl_if_head_eq_charcode:eNT { \tl_trim_spaces:V\l_@@_tmpa_tl } [ %] + { + \seq_set_split:NnV\l_@@_tmpa_seq{/}\l_@@_tmpa_tl + \pdfmanagement_add:nne {Catalog} { OpenAction } + { + << + /S/GoTo \c_space_tl + /D~\l_@@_tmpa_tl\c_space_tl + /SD~[\pdf_object_ref:e{__tag/struct/\g_@@_tree_openaction_struct_tl} +% \end{macrocode} +% there should be always a /Fit etc in the array but better play safe here ... +% \begin{macrocode} + \int_compare:nNnTF{ \seq_count:N \l_@@_tmpa_seq } > {1} + { /\seq_item:Nn\l_@@_tmpa_seq{2} } + { ] } + >> + } + } + } + } +% \end{macrocode} +% % \begin{macrocode} \hook_gput_code:nnn{shipout/lastpage}{tagpdf} { @@ -115,6 +178,7 @@ { Catalog } { StructTreeRoot } { \pdf_object_ref:n { @@/struct/0 } } + \@@_tree_update_openaction: } } % \end{macrocode} |