Le 30/06/2011 12:57, Patrick Gundlach a écrit :
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.

Patrick, LuaTeX is supposed to put an end to dirty tricks :)
It's nice anyway. Some comment in your code.

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

You could make global_pagebox local. Actually you could make do without new_page(), with add_to_page() initializing global_pagebox if nil.

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

You have to give a different id to all dest, otherwise TeX will complain.

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]"

Oh no, no border on links, please!

Best,
Paul

Reply via email to