[luatex] Problem with drawing pdf

Arno Trautmann Arno.Trautmann at gmx.de
Thu Jun 7 18:18:19 CEST 2012


Hi all,

I'm having some trouble using curves in pdf. Inspired by the article by 
Paul Isambert in the TUGboat, I am using the code shown below to draw 
circles. (I'd like to use this to encircle special positions in a text.)
This works fine on my screen. However, the circles are just missing when 
the document is printed. I guess it's just some minor(?) pdf syntax 
error that is ignored by the viewer but leads to problems with printers. 
Unfortunately, I don't have a printer here, so I cannot test things 
easily … does anyone have a hint what's wrong?

Cheers
Arno

\directlua{
function pdf_print (...)
   for _, str in ipairs({...}) do
     pdf.print(str .. " ")
   end
   pdf.print("\string\n")
end

function move (p)
   pdf_print(p[1],p[2],"m")
end

function curve(p1,p2,p3)
   pdf_print(p1[1], p1[2],
             p2[1], p2[2],
             p3[1], p3[2], "c")
end

function stroke ()
   pdf_print("S")
end

function mysloppycircle(center,radius)
   local left = {center[1] - radius, center[2]}
   local lefttop = {left[1], left[2] + 1.45*radius}
   local leftbot = {lefttop[1], lefttop[2] - 2.9*radius}
   local right = {center[1] + radius, center[2]}
   local righttop = {right[1], right[2] + 1.45*radius}
   local rightbot = {right[1], right[2] - 1.45*radius}

   local right_end = (right)

   move (right)

   curve (righttop,lefttop,left)
   curve (leftbot,rightbot,right_end)

   stroke()
end
}

\long\def\luadraw#1{%
   \vbox to 0bp{%
     \vfil
     \luatexlatelua{pdf_print("q") #1 pdf_print("Q")}%
   }%
}

\luadraw{mysloppycircle({21,-9},5)} test

\bye


More information about the luatex mailing list