ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Getting page width and height in Lua
@ 2020-04-30 14:36 Jack Steyn
  2020-04-30 15:00 ` Wolfgang Schuster
  0 siblings, 1 reply; 2+ messages in thread
From: Jack Steyn @ 2020-04-30 14:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 386 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 520 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Getting page width and height in Lua
  2020-04-30 14:36 Getting page width and height in Lua Jack Steyn
@ 2020-04-30 15:00 ` Wolfgang Schuster
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Schuster @ 2020-04-30 15:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Jack Steyn

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-30 15:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30 14:36 Getting page width and height in Lua Jack Steyn
2020-04-30 15:00 ` Wolfgang Schuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).