luatexbase.provides_module { name = "x", version = "0.0", author = "Martin Mareš", } x = { } local number_sp_in_a_pdf_point = 65782 function math.round(num, idp) if idp and idp>0 then local mult = 10^idp return math.floor(num * mult + 0.5) / mult end return math.floor(num + 0.5) end function x.transform(parent) local head = parent.list while head do local id = head.id if id == 0 and head.subtype == 1 then -- Line if node.has_attribute(head, 222, 1) then local wd = math.round(head.width / number_sp_in_a_pdf_point, 2) local ht = math.round((head.height + head.depth) / number_sp_in_a_pdf_point, 2) local dp = math.round(head.depth / number_sp_in_a_pdf_point, 2) local bg = node.new("whatsit", "pdf_literal") bg.data = string.format("q 1 0 0 RG 0 %g %g %g re s Q", 0, wd, -ht) parent.list = node.insert_before(parent.list, head, bg) end end x.transform(head) head = head.next end end function x.output() texio.write("### output ###") local outbox = tex.getbox(255) x.transform(outbox) end