8

I can access e.g. the object number of a page in luatex with \pdffeedback. Is there a way to get the same value in pure lua code?

\documentclass{article}
\usepackage{luacode}
\begin{luacode}

function showpageobjnum (page)
  a="??????" -- how to get the object number of page here?
  tex.sprint(a)
 end 

\end{luacode}

\begin{document}
% to increase the numbers a bit
\pdfextension obj reserveobjnum 
\pdfextension obj reserveobjnum

\pdffeedback pageref 1 %gives 3

\directlua{showpageobjnum(1)}

\end{document}
  • 1
    Just out of curiosity, what can that information be used for? – daleif Jul 2 '18 at 16:32
  • 2
    @daleif I need it to write the /Pg key in a dictionary. – Ulrike Fischer Jul 2 '18 at 17:32
10

To find things like this in LuaTeX you either have to guess the names or look into the source code. The documentation of LuaTeX is very incomplete, but (almost?) all pdffeedback values are exposed in the pdf namespace:

\documentclass{article}
\usepackage{luacode}
\begin{luacode}

function showpageobjnum (page)
  a=pdf.pageref(1)
  tex.sprint(a)
 end 

\end{luacode}

\begin{document}
% to increase the numbers a bit
\pdfextension obj reserveobjnum 
\pdfextension obj reserveobjnum

\pdffeedback pageref 1 %gives 3

\directlua{showpageobjnum(1)}

\end{document}

This is undocumented, so it might disappear without notice.

EDIT: Starting with the yet unreleased LuaTeX version 1.09, pdf.pageref will probably be renamed into pdf.getpageref. The old name is still available for compatibility but might get deleted in a later version.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.