[luatex] Creating pdf objects in \latelua

Paweł Jackowski P.Jackowski at gust.org.pl
Thu Oct 1 21:43:19 CEST 2009


Paweł Jackowski wrote:
> Hello,
> 
> can we somehow write pdf objects within \latelua? Obviously we cannot 
> use pdf.immediateobj() as it writes the data to a content stream 
> generating invalid output. If I use pdf.obj(), then how to reference it 
> without explcit \pdfrefobj somewhere later? I'd like to avoid it as it 
> does not actually write the object into the pdf output but inserts a 
> pdf_refobj node into the list, which will take an effect no sooner then 
> the next \shipout, right? But can we do better?

I think I've got that... The code executed inside late_lua node may 
`know' the self-late_lua node object. If so, it may also call pdf.obj() 
AND insert pdf_refobj just after itself. Seems to work but I'm not sure 
if luatex expects rebuilding the list being currently during shipout. 
Anyone?


\lua{
   lateluas = {}
}

\def\pdflateobj#1{
   \lua{
     local late = node.new(node.id("whatsit"), node.subtype("late_lua"))
     table.insert(lateluas, late)
     late.data = [[
       local this = lateluas[]]..table.getn(lateluas)..[[]
       local next = this.next
       local robj = node.new(
         node.id("whatsit"),
         node.subtype("pdf_refobj")
       )
       robj.objnum = pdf.obj("#1")
       this.next = robj	robj.prev = this
       robj.next = next	next.prev = robj
    ]]
    %print(late.data)
    node.write(late)
   }
}

\pdflateobj{[1 2 3]}
\pdflateobj{<</This /That>>}

-- 
Pawe/l Jackowski
P.Jackowski at gust.org.pl


More information about the luatex mailing list