From f4f829dbac0e8d0691406286a732a0d1308ef49a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Wed, 1 Jul 2020 14:10:30 +0200 Subject: [PATCH] Some PDF toks variables --- luametalatex-back-pdf.lua | 2 +- luametalatex-baseregisters.lua | 5 +++-- luametalatex-pdf-pagetree.lua | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/luametalatex-back-pdf.lua b/luametalatex-back-pdf.lua index 00a0c3d..d80264e 100644 --- a/luametalatex-back-pdf.lua +++ b/luametalatex-back-pdf.lua @@ -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([[<>%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([[<>%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() diff --git a/luametalatex-baseregisters.lua b/luametalatex-baseregisters.lua index 7b041f1..2b47c16 100644 --- a/luametalatex-baseregisters.lua +++ b/luametalatex-baseregisters.lua @@ -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 diff --git a/luametalatex-pdf-pagetree.lua b/luametalatex-pdf-pagetree.lua index 767849a..277fc3f 100644 --- a/luametalatex-pdf-pagetree.lua +++ b/luametalatex-pdf-pagetree.lua @@ -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('<>', 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]