Some PDF toks variables

This commit is contained in:
Marcel Krüger 2020-07-01 14:10:30 +02:00
parent acc0ad0559
commit f4f829dbac
3 changed files with 8 additions and 4 deletions

View File

@ -47,7 +47,7 @@ token.luacmd("shipout", function()
local out, resources, annots = writer(pfile, list, fontdirs, usedglyphs, colorstacks)
cur_page = nil
local content = pfile:stream(nil, '', out)
pfile:indirect(page, string.format([[<</Type/Page/Parent %i 0 R/Contents %i 0 R/MediaBox[0 %i %i %i]/Resources<<%s>>%s>>]], parent, content, -math.ceil(list.depth/65781.76), math.ceil(list.width/65781.76), math.ceil(list.height/65781.76), resources, annots))
pfile:indirect(page, string.format([[<</Type/Page/Parent %i 0 R/Contents %i 0 R/MediaBox[0 %i %i %i]/Resources<<%s%s>>%s%s>>]], parent, content, -math.ceil(list.depth/65781.76), math.ceil(list.width/65781.76), math.ceil(list.height/65781.76), resources, pdfvariable.pageresources, annots, pdfvariable.pageattr))
node.flush_list(list)
token.put_next(token.create'immediateassignment', token.create'global', token.create'deadcycles', token.create(0x30), token.create'relax')
token.scan_token()

View File

@ -149,9 +149,10 @@ pdf_variable(count_code, token.scan_int, 'forcepagebox', 0, true) -- Considered
pdf_variable(count_code, token.scan_int, 'imageresolution', 72, true) -- TODO Also 0 should be the same as 72 ?!?!?!?
-- The following two relate to pk fonts which we don't support, so they are ignored on a different level
pdf_variable(count_code, token.scan_int, 'pkresolution', 72)
-- pdf_variable(toks_code, token.scan_string, 'pkmode', '')
pdf_toks('pkmode', '')
pdf_toks('pageattr', '')
pdf_toks('pagesattr', '')
pdf_toks('pageresources', '')
function tex.getbodydir() return tex.bodydirection end

View File

@ -1,6 +1,7 @@
local min = math.min
local format = string.format
local concat = table.concat
local pdfvariable = pdf.variable
local function write(pdf, tree, total, max)
tree = tree or pdf.pages
if #tree == 0 then
@ -22,11 +23,13 @@ local function write(pdf, tree, total, max)
local parentid = pdf:getobj()
newtree[-(i//6)] = parentid
parent = format("/Parent %i 0 R", parentid)
elseif #tree <= 6 then
parent = pdfvariable.pagesattr
end
pdf:indirect(id, format('<</Type/Pages%s/Kids[%s 0 R]/Count %i>>', parent, concat(tree, ' 0 R ', 6*i+1, min(#tree, 6*i+6)), min(remaining, max)))
remaining = remaining - max
end
if #parent > 0 then
if newtree[0] then
return write(pdf, newtree, total, max*6)
end
return newtree[1]