[luatex] FYI: my experiments on tex.shipout() and links

Patrick Gundlach patrick at gundla.ch
Thu Jun 30 12:57:25 CEST 2011


Just in case someone is interested in my experiments with tex.shipout and the pdf_dest, pdf_start_link nodes, here is a simple example. Not clever, but you get the point.

Thanks to all again!

Patrick




test.tex:
-------------------
\directlua{dofile("mknodes.lua")}
\end
-------------------

mknodes.lua:
-------------------
local tenpt = 10 * 2^16

function add_to_page( list )
  local tail = node.tail(global_pagebox)
  tail.next = list
  list.prev = tail
end

function new_page()
  global_pagebox = node.new("vlist")
end

function shipout()
  local x = node.vpack(global_pagebox)
  tex.box[666] = x
  tex.shipout(666)
end

function mkrule( size )
  local r = node.new("rule")
  r.width  = size * 2
  r.height = size
  r.depth  = size
  return r
end
function mkdest()
  local d = node.new("whatsit","pdf_dest")
  d.named_id = 0
  d.dest_id = 1
  d.dest_type = 3
  return d
end

new_page()

add_to_page(mkdest())
add_to_page(mkrule(tenpt))
add_to_page(mkrule(2 * tenpt))
add_to_page(mkrule(tenpt))

shipout()
new_page()

local start_link = node.new("whatsit","pdf_start_link")
local end_link = node.new("whatsit","pdf_end_link")
local action = node.new("action")

action.action_type = 1
action.action_id = 1

start_link.width = 2 * tenpt
start_link.height = tenpt
start_link.depth  = tenpt
start_link.action = action
start_link.link_attr = "/C [0.9 1 0] /Border [0 0 2]"

local r = mkrule(tenpt)

start_link.next = r
r.next = end_link
node.slide(start_link)

local h = node.hpack(start_link)
add_to_page(h)


add_to_page(mkrule(2 * tenpt))
add_to_page(mkrule(tenpt))

shipout()
-------------------




More information about the luatex mailing list