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}
2
  • 1
    Just out of curiosity, what can that information be used for?
    – daleif
    Commented Jul 2, 2018 at 16:32
  • 2
    @daleif I need it to write the /Pg key in a dictionary. Commented Jul 2, 2018 at 17:32

1 Answer 1

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .