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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to