# How to access \pdffeedback values in lua code?

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}

• Just out of curiosity, what can that information be used for? Jul 2 '18 at 16:32
• @daleif I need it to write the /Pg key in a dictionary. Jul 2 '18 at 17:32

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.