Some fixes

This version managed to compile by Bachelor's thesis after I removed all
images, microtype and outline commands.
This commit is contained in:
Marcel Krüger 2020-06-06 04:09:56 +02:00
parent e59393de6f
commit c83b7ffc5e
3 changed files with 12 additions and 9 deletions

View File

@ -111,7 +111,8 @@ callback.register("stop_run", function()
nodestat[#nodestat + 1] = string.format("%d %s", c, whatsits[id]) nodestat[#nodestat + 1] = string.format("%d %s", c, whatsits[id])
end end
texio.write_nl(" " .. table.concat(nodestat, ', ')) texio.write_nl(" " .. table.concat(nodestat, ', '))
texio.write_nl(string.format("Output written on %s (%d pages, %d bytes).\n", pdfname, pages, size)) texio.write_nl(string.format("Output written on %s (%d pages, %d bytes).", pdfname, pages, size))
texio.write_nl(string.format("Transcript written on %s.\n", status.log_name))
end, "Finish PDF file") end, "Finish PDF file")
token.luacmd("pdfvariable", function() token.luacmd("pdfvariable", function()
for n, t in pairs(pdf.variable_tokens) do for n, t in pairs(pdf.variable_tokens) do

View File

@ -1,8 +1,7 @@
local min = math.min local min = math.min
local format = string.format local format = string.format
local concat = table.concat local concat = table.concat
local _ENV = {} local function write(pdf, tree, total, max)
function write(pdf, tree, total, max)
tree = tree or pdf.pages tree = tree or pdf.pages
if #tree == 0 then if #tree == 0 then
local id = pdf:getobj() local id = pdf:getobj()
@ -20,7 +19,7 @@ function write(pdf, tree, total, max)
local id = tree[-i] local id = tree[-i]
newtree[i+1] = id newtree[i+1] = id
if 0 == i % 6 and #tree > 6 then if 0 == i % 6 and #tree > 6 then
local parentid = pdf:getid() local parentid = pdf:getobj()
newtree[-(i//6)] = parentid newtree[-(i//6)] = parentid
parent = format("/Parent %i 0 R", parentid) parent = format("/Parent %i 0 R", parentid)
end end
@ -28,11 +27,11 @@ function write(pdf, tree, total, max)
remaining = remaining - max remaining = remaining - max
end end
if #parent > 0 then if #parent > 0 then
return writetree(pdf, newtree, total, max*6) return write(pdf, newtree, total, max*6)
end end
return newtree[1] return newtree[1]
end end
function newpage(pdf) local function newpage(pdf)
local pageid = pdf:getobj() local pageid = pdf:getobj()
local pagenumber = #pdf.pages local pagenumber = #pdf.pages
pdf.pages[pagenumber+1] = pageid pdf.pages[pagenumber+1] = pageid
@ -41,4 +40,7 @@ function newpage(pdf)
end end
return pageid, pdf.pages[-(pagenumber//6)] return pageid, pdf.pages[-(pagenumber//6)]
end end
return _ENV return {
write = write,
newpage = newpage,
}

View File

@ -55,7 +55,7 @@ local function indirect(pdf, num, content, isfile)
pdf.file:write'\nendobj\n' pdf.file:write'\nendobj\n'
return num return num
end end
local function delayed(pdf, num, content, isfile) local function delay(pdf, num, content, isfile)
if not num then num = pdf:getobj() end if not num then num = pdf:getobj() end
if pdf[num] ~= assigned then if pdf[num] ~= assigned then
error[[Invalid object]] error[[Invalid object]]
@ -123,7 +123,7 @@ local pdfmeta = {
stream = stream, stream = stream,
newpage = pagetree.newpage, newpage = pagetree.newpage,
writepages = pagetree.write, writepages = pagetree.write,
delayed = delayed, delayed = delay,
delayedstream = delayedstream, delayedstream = delayedstream,
reference = reference, reference = reference,
written = written, written = written,