Getting page width and height in Lua
![](https://secure.gravatar.com/avatar/1969501a17662d72b3c7d4c2e0c3b642.jpg?s=120&d=mm&r=g)
If I want to get the paper width and height to use in some Lua code, I can use: local paperwidth, paperheight = backends.pdf.codeinjections.getpagedimensions() But what if I want to get the page width and height? That is, the width and height of the first argument in the two-argument version of \setuppapersize. Does anyone know how I can obtain these using Lua? Many thanks, Jack
![](https://secure.gravatar.com/avatar/74d41c3215dcdd377343cdc47311757c.jpg?s=120&d=mm&r=g)
Jack Steyn schrieb am 30.04.2020 um 16:36:
If I want to get the paper width and height to use in some Lua code, I can use:
local paperwidth, paperheight = backends.pdf.codeinjections.getpagedimensions()
But what if I want to get the page width and height? That is, the width and height of the first argument in the two-argument version of \setuppapersize. Does anyone know how I can obtain these using Lua?
You can use tex.dimen[...] or tex.dimen.<NAME> but all values are in scaled points. \setuppapersize[A5][A4] \setuplayout[location=middle] \showframe \starttext \startluacode local pagedimensions = { "paperwidth", "paperheight", "printpaperwidth", "printpaperheight", } context.starttabulate() for _, pagedimension in next, pagedimensions do context.NC() context.Word(pagedimension) context.NC() context((number.tomillimeters(tex.dimen[pagedimension],"%.F%s"))) context.NC() context.NR() end context.stoptabulate() \stopluacode \stoptext Wolfgang
participants (2)
-
Jack Steyn
-
Wolfgang Schuster