summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tagpdf/tagpdf-tree.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/tagpdf/tagpdf-tree.dtx')
-rw-r--r--macros/latex/contrib/tagpdf/tagpdf-tree.dtx133
1 files changed, 92 insertions, 41 deletions
diff --git a/macros/latex/contrib/tagpdf/tagpdf-tree.dtx b/macros/latex/contrib/tagpdf/tagpdf-tree.dtx
index 6bb4aa9980..ecbd96f04e 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.97, released 2022-08-24}
+% \date{Version 0.98, released 2022-12-22}
% \maketitle
% \begin{implementation}
% \begin{macrocode}
%<@@=tag>
%<*header>
-\ProvidesExplPackage {tagpdf-tree-code} {2022-08-24} {0.97}
+\ProvidesExplPackage {tagpdf-tree-code} {2022-12-22} {0.98}
{part of tagpdf - code related to writing trees and dictionaries to the pdf}
%</header>
% \end{macrocode}
@@ -81,6 +81,21 @@
}
}
% \end{macrocode}
+% \subsection{Check structure}
+% \begin{macro}{\@@_tree_final_checks:}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_tree_final_checks:
+ {
+ \int_compare:nNnF {\seq_count:N\g_@@_struct_stack_seq}={1}
+ {
+ \msg_warning:nn {tag}{tree-struct-still-open}
+ \int_step_inline:nnn{2}{\seq_count:N\g_@@_struct_stack_seq}
+ {\tag_struct_end:}
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Catalog: MarkInfo and StructTreeRoot}
% The StructTreeRoot and the MarkInfo entry must be added to the catalog.
% We do it late so that we can win, but before the pdfmanagement hook.
@@ -109,18 +124,34 @@
% \begin{macro}{\@@_tree_write_structtreeroot:}
% This writes out the root object.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_tree_write_structtreeroot:
- {
- \@@_prop_gput:cnx
- { g_@@_struct_0_prop }
- { ParentTree }
- { \pdf_object_ref:n { @@/tree/parenttree } }
- \@@_prop_gput:cnx
- { g_@@_struct_0_prop }
- { RoleMap }
- { \pdf_object_ref:n { @@/tree/rolemap } }
- \@@_struct_write_obj:n { 0 }
- }
+\pdf_version_compare:NnTF < {2.0}
+ {
+ \cs_new_protected:Npn \@@_tree_write_structtreeroot:
+ {
+ \@@_prop_gput:cnx
+ { g_@@_struct_0_prop }
+ { ParentTree }
+ { \pdf_object_ref:n { @@/tree/parenttree } }
+ \@@_prop_gput:cnx
+ { g_@@_struct_0_prop }
+ { RoleMap }
+ { \pdf_object_ref:n { @@/tree/rolemap } }
+ \@@_struct_write_obj:n { 0 }
+ }
+ }
+% \end{macrocode}
+% no RoleMap in pdf 2.0
+% \begin{macrocode}
+ {
+ \cs_new_protected:Npn \@@_tree_write_structtreeroot:
+ {
+ \@@_prop_gput:cnx
+ { g_@@_struct_0_prop }
+ { ParentTree }
+ { \pdf_object_ref:n { @@/tree/parenttree } }
+ \@@_struct_write_obj:n { 0 }
+ }
+ }
% \end{macrocode}
% \end{macro}
%
@@ -300,7 +331,10 @@
% \begin{variable}{@@/tree/rolemap}
% At first we reserve again an object.
% \begin{macrocode}
-\pdf_object_new:n { @@/tree/rolemap }
+\pdf_version_compare:NnT < {2.0}
+ {
+ \pdf_object_new:n { @@/tree/rolemap }
+ }
% \end{macrocode}
% \end{variable}
%
@@ -308,13 +342,26 @@
% This writes out the rolemap, basically it simply pushes out
% the dictionary which has been filled in the role module.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_tree_write_rolemap:
+\pdf_version_compare:NnTF < {2.0}
{
- \pdf_object_write:nnx { @@/tree/rolemap }{dict}
- {
+ \cs_new_protected:Npn \@@_tree_write_rolemap:
+ {
+ \prop_map_inline:Nn\g_@@_role_rolemap_prop
+ {
+ \pdfdict_gput:nnx {g_@@_role/RoleMap_dict}
+ {##1}
+ {\pdf_name_from_unicode_e:n{##2}}
+ }
+ \pdf_object_write:nnx { @@/tree/rolemap }{dict}
+ {
\pdfdict_use:n{g_@@_role/RoleMap_dict}
- }
+ }
+ }
+ }
+ {
+ \cs_new_protected:Npn \@@_tree_write_rolemap:{}
}
+
% \end{macrocode}
% \end{macro}
%
@@ -360,36 +407,39 @@
% \end{macro}
% \subsection{Namespaces}
% Namespaces are handle in the role module, here is the code to write them out.
-% Namespaces are only relevant for pdf2.0 but we don't care, it doesn't harm.
+% Namespaces are only relevant for pdf2.0.
% \begin{variable}{@@/tree/namespaces}
% \begin{macrocode}
-\pdf_object_new:nn{ @@/tree/namespaces }{array}
+\pdf_object_new:n { @@/tree/namespaces }
% \end{macrocode}
% \end{variable}
% \begin{macro}{\@@_tree_write_namespaces:}
% \begin{macrocode}
\cs_new_protected:Npn \@@_tree_write_namespaces:
{
- \prop_map_inline:Nn \g_@@_role_NS_prop
- {
- \pdfdict_if_empty:nF {g_@@_role/RoleMapNS_##1_dict}
- {
- \pdf_object_write:nnx {@@/RoleMapNS/##1}{dict}
- {
- \pdfdict_use:n {g_@@_role/RoleMapNS_##1_dict}
- }
- \pdfdict_gput:nnx{g_@@_role/Namespace_##1_dict}
- {RoleMapNS}{\pdf_object_ref:n {@@/RoleMapNS/##1}}
- }
- \pdf_object_write:nnx{tag/NS/##1}{dict}
- {
- \pdfdict_use:n {g_@@_role/Namespace_##1_dict}
- }
- }
- \pdf_object_write:nx {@@/tree/namespaces} %array
- {
- \prop_map_tokens:Nn \g_@@_role_NS_prop{\use_ii:nn}
- }
+ \pdf_version_compare:NnF < {2.0}
+ {
+ \prop_map_inline:Nn \g_@@_role_NS_prop
+ {
+ \pdfdict_if_empty:nF {g_@@_role/RoleMapNS_##1_dict}
+ {
+ \pdf_object_write:nnx {@@/RoleMapNS/##1}{dict}
+ {
+ \pdfdict_use:n {g_@@_role/RoleMapNS_##1_dict}
+ }
+ \pdfdict_gput:nnx{g_@@_role/Namespace_##1_dict}
+ {RoleMapNS}{\pdf_object_ref:n {@@/RoleMapNS/##1}}
+ }
+ \pdf_object_write:nnx{tag/NS/##1}{dict}
+ {
+ \pdfdict_use:n {g_@@_role/Namespace_##1_dict}
+ }
+ }
+ \pdf_object_write:nnx {@@/tree/namespaces}{array}
+ {
+ \prop_map_tokens:Nn \g_@@_role_NS_prop{\use_ii:nn}
+ }
+ }
}
% \end{macrocode}
% \end{macro}
@@ -404,6 +454,7 @@
\bool_if:NT\g_@@_active_tree_bool
{
\hook_use:n {tagpdf/finish/before}
+ \@@_tree_final_checks:
\@@_tree_write_parenttree:
\@@_tree_write_rolemap:
\@@_tree_write_classmap: