-- Scribble v.0.1
-- G.C.Wraith 03/07/02

do
local PDF = {}
settag(PDF,newtag())

local END = function (x)
            x:end_page()
            x:close()
            x:delete()
            execute("settype "..x.file.." pdf")
            end -- function

settagmethod(tag(PDF),"gettable",function (a,i)
             local f = getglobal("PDF_"..i)
             if f == nil then return rawgettable(a,i)
             else
               return function (a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
                      return %f(a1.p,a2,a3,a4,a5,a6,a7,a8,a9,a10)
                      end -- function
             end -- if
          end)            

BEGIN = function (file)
         local p = PDF_new()
         assert(PDF_open_file(p,file))
         local x = { p = p, file = file, END = %END}
         settag(x,tag(%PDF))
         return x
         end -- function
end -- do

A0 = { width = 2380, height = 3368 }
A1 = { width = 1684, height = 2380 }
A2 = { width = 1190, height = 1684 }
A3 = { width = 842, height = 1190 }
A4 = { width = 595, height = 842 }
A5 = { width = 421, height = 595 }
A6 = { width = 297, height = 421 }
B5 = { width = 501, height = 709 }
Letter = { width = 612, height = 792 }
Legal = { width = 612, height = 1008 }
Ledger = { width = 1224, height = 792 }

dofile(arg[1])

----------------------------