latex3 / tagpdf

Tagging support code for LaTeX
59 stars 7 forks source link

lua error if object number of a structure is larger than 65535 #97

Closed u-fischer closed 6 months ago

u-fischer commented 6 months ago

If the object number is larger than 65535 there is a lua error from the command that tries to retrieve the object number:

\DocumentMetadata{uncompress,testphase=phase-I}
\documentclass{article}
\begin{document}
% lua code in tagpdf-lua
%local function __tag_pdf_object_ref (name)
%   local tokenname = 'c__pdf_backend_object_'..name..'_int'
%   local object = token.create(tokenname).index..' 0 R'
%   return object
%end

\ExplSyntaxOn
xxx
\int_step_inline:nn{65521}  % 65520 works -> total 65551
 {
  \pdfextension~obj~reserveobjnum
 }
\newpage 

\tagstructbegin{tag=Span}\tagmcbegin{}blub\tagmcend\tagstructend 
\int_show:c{c__pdf_backend_object___tag/struct/2_int} 
\ExplSyntaxOff
\end{document}

gives

> \c__pdf_backend_object___tag/struct/2_int=65536.
<recently read> }

l.190 ...c{c__pdf_backend_object___tag/struct/2_int}

? 

[2] (./test-utf8.aux)
 ***********
LaTeX2e <2024-06-01> pre-release-1 (develop 2024-2-16 branch)
L3 programming layer <2024-02-13>
 ***********
...ro/Documents/gitinstalltexmf/tex/latex/tagpdf/tagpdf.lua:381: attempt to concatenate a nil value (field 'index')
stack traceback:
    ...ro/Documents/gitinstalltexmf/tex/latex/tagpdf/tagpdf.lua:381: in upvalue '__tag_pdf_object_ref'
    ...ro/Documents/gitinstalltexmf/tex/latex/tagpdf/tagpdf.lua:787: in field 'fill_parent_tree_line'
    ...ro/Documents/gitinstalltexmf/tex/latex/tagpdf/tagpdf.lua:815: in field 'output_parenttree'
    [\directlua]:1: in main chunk.
\lua_now:e #1->\__lua_now:n {#1}

l.192 \end{document}