back-pdf.lua /size: 1458 b    last modification: 2020-07-01 14:35
1if not modules then modules = { } end modules ['back-pdf'] = {
2    version   = 1.001,
3    comment   = "companion to back-pdf.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
9-- We hide the pdf table from users so that we can guarantee no interference with
10-- the way we manage resources, info, etc. Users should use the \type {lpdf}
11-- interface instead. If needed I will provide replacement functionality.
12
13local setmetatableindex = table.setmetatableindex
14
15interfaces.implement {
16    name      = "setpdfcompression",
17    arguments = { "integer", "integer" },
18    actions   = lpdf.setcompression,
19}
20
21do
22
23    local dummy  = function() end
24    local report = logs.reporter("backend")
25
26    local function unavailable(t,k)
27        report("calling unavailable pdf.%s function",k)
28        t[k] = dummy
29        return dummy
30    end
31
32    updaters.register("backend.update",function()
33        --
34        -- For now we keep this for tikz. If really needed some more can be made
35        -- accessible but it has to happen in a controlled way then, for instance
36        -- by first loading or enabling some compatibility layer so that we can
37        -- trace possible interferences.
38        --
39        pdf = {
40            immediateobj = pdf.immediateobj
41        }
42        setmetatableindex(pdf,unavailable)
43    end)
44
45end
46
47backends.install("pdf")
48