On Tue, Apr 2, 2019 at 7:18 AM luigi scarso <luigi.scarso@gmail.com> wrote:


On Tue, Apr 2, 2019 at 12:23 AM Reinhard Kotucha <reinhard.kotucha@web.de> wrote:
Hi,
when I run the example on page 261/262 of the LuaTeX Manual and the
input file ("foo.pdf" in the example) doesn't exist, I get

  Segmentation fault (core dumped)

on x86_64-linux.

 
This is ok
$ luatex --fmt=luatex-plain  "test-plain.tex"

\directlua{
local operatortable = { }

operatortable.Do = function(scanner,info)
    local resources = info.resources
    if resources then
            local val     = scanner:pop()
            local name    = val[2]
            local xobject = resources.XObject
            print(info.space .. "Uses XObject " .. name)
            local resources = xobject.Resources
            if resources then
                local newinfo = {
                    space     = info.space .. " ",
                    resources = resources,
                }
                pdfscanner.scan(entry, operatortable, newinfo)
            end
      end
end


local function Analyze(filename)
    local doc = pdfe.open(filename)
    if doc then
        local pages = doc.Pages
        for i=1,#pages do
            local page = pages[i]
            local info = {
              space     = " " ,
              resources = page.Resources,
            }
            print("Page " .. i)
         --[==[ pdfscanner.scan(page.Contents,operatortable,info)]==]
            pdfscanner.scan(page.Contents(),operatortable,info)
        end
    end
end

Analyze("foo.pdf")

}
\end

--
luigi