Hello,
@Aditya: Thanks for the tip - maybe some inspiration for me.
Anyway, I keep on trying to create my previously described function with Lua.
Now, I have a code which does much expected, but I'm not able to pass the desired content to setups/layer:
----
\setupbodyfont[30pt]
\starttext
A
\definelayer [beforetext][width=\overlaywidth,height=\overlayheight]
\defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]
\startsetups[beforetext]
\setlayer[beforetext][preset=righttop]{\framed[width=2in]{\directlua{context(userdata.LPr.text)}}}
\stopsetups
\startluacode
userdata = userdata or {}
userdata.LPr = userdata.LPr or {}
for i = 1, 2 do
context.startTEXpage{background="foreground,beforetext"}
userdata.LPr.text = "BEF" .. i
context.externalfigure({"cow"},{width="30cm"})
context.stopTEXpage()
end
\stopluacode
Z
\stoptext
----
Both images of the cow have "BEF2" in the top right corner, but there should be "BEF1" on the former and "BEF2" on the latter.
I'm trying to pass the text string ("BEF" .. i) via userdata, but it doesn't work.
So how to do it?
Lukas
On Tue, 15 Jan 2013 13:25:04 +0100, Aditya Mahajan
On Tue, 15 Jan 2013, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
(Finally: I'd like to achieve a Lua function which will copy all pages of a .pdf file, keeping size of each page, and adding a customizable string with page-in-the-pdf number (with default value "<page-i>/<n-pages>"), being placed to the right top corner of the i-th page. All to be provided by Lua.)
A few years ago I wrote a module that, amongst other things, did this. (The mail purpose of the module was to cut 2 column journal papers to one column PDF so that they are easy to read on an eink reader. I haven't used this in a while, so it may not work out of the box).
https://github.com/adityam/cut-n-paste/blob/master/tex/context/third/cut-n-p...
In this case, I used a MetaPost overylay to draw the page number (search for cnp:text). The user could manipulate the location of the page number by using the location key (which had to be a valid Metapost pair).
Aditya
-- Ing. Lukáš Procházka [mailto:LPr@pontex.cz] Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038