Getting page width and height in Lua
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
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