Skip to content

alias PageOrderIndexCallback


(alias) PageOrderIndexCallback = fun(pagenumber: integer) -> string

This is one that experts can use to juggle the page tree, a data structure that determines the order in a PDF file:

Say that we have 12 pages, then we can do this:

callback.register("page_order_index",function(page)
        if page ==  1 then return 12
    elseif page ==  2 then return 11
    elseif page == 11 then return  2
    elseif page == 12 then return  1
    else                   return page
    end
end)

This will swap the first two and last two pages. You need to know the number of pages which is a side effect of the implementation. When you mess things up \unknown\ don't complain.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!