1if not modules then modules = { } end modules ['lpdf-res'] = {
2 version = 1.001,
3 comment = "companion to lpdf-ini.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local codeinjections = backends.codeinjections
10
11local nuts = nodes.nuts
12local tonut = nodes.tonut
13
14local setwhd = nuts.setwhd
15local setlist = nuts.setlist
16
17local new_hlist = nuts.pool.hlist
18
19local boxresources = tex.boxresources
20local saveboxresource = boxresources.save
21local useboxresource = boxresources.use
22local getboxresourcedimensions = boxresources.getdimensions
23
24local pdfcollectedresources = lpdf.collectedresources
25
26function codeinjections.registerboxresource(n,offset)
27 local r = saveboxresource(n,nil,pdfcollectedresources(),true,0,offset or 0)
28 return r
29end
30
31function codeinjections.restoreboxresource(index)
32 local hbox = new_hlist()
33 local list, wd, ht, dp = useboxresource(index)
34 setlist(hbox,tonut(list))
35 setwhd(hbox,wd,ht,dp)
36 return hbox
37end
38
39function codeinjections.boxresourcedimensions(index)
40 return getboxresourcedimensions(index)
41end
42 |