summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lpdf-mis.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lpdf-mis.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/lpdf-mis.lua150
1 files changed, 79 insertions, 71 deletions
diff --git a/Master/texmf-dist/tex/context/base/lpdf-mis.lua b/Master/texmf-dist/tex/context/base/lpdf-mis.lua
index 426c00286a9..174d17427fa 100644
--- a/Master/texmf-dist/tex/context/base/lpdf-mis.lua
+++ b/Master/texmf-dist/tex/context/base/lpdf-mis.lua
@@ -16,40 +16,38 @@ if not modules then modules = { } end modules ['lpdf-mis'] = {
-- course there are a couple of more changes.
local next, tostring = next, tostring
-local format = string.format
+local format, gsub = string.format, string.gsub
local texset = tex.set
local backends, lpdf, nodes = backends, lpdf, nodes
-local nodeinjections = backends.pdf.nodeinjections
-local codeinjections = backends.pdf.codeinjections
-local registrations = backends.pdf.registrations
+local nodeinjections = backends.pdf.nodeinjections
+local codeinjections = backends.pdf.codeinjections
+local registrations = backends.pdf.registrations
-local copy_node = node.copy
+local copy_node = node.copy
-local nodepool = nodes.pool
+local nodepool = nodes.pool
+local pdfliteral = nodepool.pdfliteral
+local register = nodepool.register
-local pdfliteral, register = nodepool.pdfliteral, nodepool.register
+local pdfdictionary = lpdf.dictionary
+local pdfarray = lpdf.array
+local pdfboolean = lpdf.boolean
+local pdfconstant = lpdf.constant
+local pdfreference = lpdf.reference
+local pdfunicode = lpdf.unicode
+local pdfverbose = lpdf.verbose
+local pdfstring = lpdf.string
+local pdfflushobject = lpdf.flushobject
+local pdfflushstreamobject = lpdf.flushstreamobject
-local pdfdictionary = lpdf.dictionary
-local pdfarray = lpdf.array
-local pdfboolean = lpdf.boolean
-local pdfconstant = lpdf.constant
-local pdfreference = lpdf.reference
-local pdfunicode = lpdf.unicode
-local pdfverbose = lpdf.verbose
-local pdfstring = lpdf.string
-local pdfflushobject = lpdf.flushobject
-local pdfimmediateobject = lpdf.immediateobject
+local variables = interfaces.variables
-local variables = interfaces.variables
-
---
-
-local positive = register(pdfliteral("/GSpositive gs"))
-local negative = register(pdfliteral("/GSnegative gs"))
-local overprint = register(pdfliteral("/GSoverprint gs"))
-local knockout = register(pdfliteral("/GSknockout gs"))
+local positive = register(pdfliteral("/GSpositive gs"))
+local negative = register(pdfliteral("/GSnegative gs"))
+local overprint = register(pdfliteral("/GSoverprint gs"))
+local knockout = register(pdfliteral("/GSknockout gs"))
local function initializenegative()
local a = pdfarray { 0, 1 }
@@ -59,10 +57,10 @@ local function initializenegative()
Range = a,
Domain = a,
}
- local negative = pdfdictionary { Type = g, TR = pdfreference(pdfimmediateobject("stream","1 exch sub",d())) }
+ local negative = pdfdictionary { Type = g, TR = pdfreference(pdfflushstreamobject("{ 1 exch sub }",d)) }
local positive = pdfdictionary { Type = g, TR = pdfconstant("Identity") }
lpdf.adddocumentextgstate("GSnegative", pdfreference(pdfflushobject(negative)))
- lpdf.adddocumentextgstate("GSPositive", pdfreference(pdfflushobject(positive)))
+ lpdf.adddocumentextgstate("GSpositive", pdfreference(pdfflushobject(positive)))
initializenegative = nil
end
@@ -95,15 +93,15 @@ end
--
-function codeinjections.addtransparencygroup()
- -- png: /CS /DeviceRGB /I true
- local d = pdfdictionary {
- S = pdfconstant("Transparency"),
- I = true,
- K = true,
- }
- lpdf.registerpagefinalizer(function() lpdf.addtopageattributes("Group",d) end) -- hm
-end
+-- function codeinjections.addtransparencygroup()
+-- -- png: /CS /DeviceRGB /I true
+-- local d = pdfdictionary {
+-- S = pdfconstant("Transparency"),
+-- I = true,
+-- K = true,
+-- }
+-- lpdf.registerpagefinalizer(function() lpdf.addtopageattributes("Group",d) end) -- hm
+-- end
-- actions (todo: store and update when changed)
@@ -162,47 +160,57 @@ function codeinjections.setupidentity(specification)
end
end
+local done = false -- using "setupidentity = function() end" fails as the meaning is frozen in register
+
local function setupidentity()
- local title = identity.title
- if not title or title == "" then
- title = tex.jobname
- end
- lpdf.addtoinfo("Title", pdfunicode(title), title)
- local subtitle = identity.subtitle or ""
- if subtitle ~= "" then
- lpdf.addtoinfo("Subject", pdfunicode(subtitle), subtitle)
- end
- local author = identity.author or ""
- if author ~= "" then
- lpdf.addtoinfo("Author", pdfunicode(author), author) -- '/Author' in /Info, 'Creator' in XMP
- end
- local creator = identity.creator or ""
- if creator ~= "" then
- lpdf.addtoinfo("Creator", pdfunicode(creator), creator) -- '/Creator' in /Info, 'CreatorTool' in XMP
- end
- lpdf.addtoinfo("CreationDate", pdfstring(lpdf.pdftimestamp(lpdf.timestamp())))
- local date = identity.date or ""
- local pdfdate = lpdf.pdftimestamp(date)
- if pdfdate then
- lpdf.addtoinfo("ModDate", pdfstring(pdfdate), date)
+ if not done then
+ local title = identity.title
+ if not title or title == "" then
+ title = tex.jobname
+ end
+ lpdf.addtoinfo("Title", pdfunicode(title), title)
+ local subtitle = identity.subtitle or ""
+ if subtitle ~= "" then
+ lpdf.addtoinfo("Subject", pdfunicode(subtitle), subtitle)
+ end
+ local author = identity.author or ""
+ if author ~= "" then
+ lpdf.addtoinfo("Author", pdfunicode(author), author) -- '/Author' in /Info, 'Creator' in XMP
+ end
+ local creator = identity.creator or ""
+ if creator ~= "" then
+ lpdf.addtoinfo("Creator", pdfunicode(creator), creator) -- '/Creator' in /Info, 'CreatorTool' in XMP
+ end
+ lpdf.addtoinfo("CreationDate", pdfstring(lpdf.pdftimestamp(lpdf.timestamp())))
+ local date = identity.date or ""
+ local pdfdate = lpdf.pdftimestamp(date)
+ if pdfdate then
+ lpdf.addtoinfo("ModDate", pdfstring(pdfdate), date)
+ else
+ -- users should enter the date in 2010-01-19T23:27:50+01:00 format
+ -- and if not provided that way we use the creation time instead
+ date = lpdf.timestamp()
+ lpdf.addtoinfo("ModDate", pdfstring(lpdf.pdftimestamp(date)), date)
+ end
+ local keywords = identity.keywords or ""
+ if keywords ~= "" then
+ keywords = gsub(keywords, "[%s,]+", " ")
+ lpdf.addtoinfo("Keywords",pdfunicode(keywords), keywords)
+ end
+ local id = lpdf.id()
+ lpdf.addtoinfo("ID", pdfstring(id), id) -- needed for pdf/x
+ done = true
else
- -- users should enter the date in 2010-01-19T23:27:50+01:00 format
- -- and if not provided that way we use the creation time instead
- date = lpdf.timestamp()
- lpdf.addtoinfo("ModDate", pdfstring(lpdf.pdftimestamp(date)), date)
- end
- local keywords = identity.keywords or ""
- if keywords ~= "" then
- keywords = string.gsub(keywords, "[%s,]+", " ")
- lpdf.addtoinfo("Keywords",pdfunicode(keywords), keywords)
+ -- no need for a message
end
- local id = lpdf.id()
- lpdf.addtoinfo("ID", pdfstring(id), id) -- needed for pdf/x
- setupidentity = function() end
end
lpdf.registerpagefinalizer(setupidentity,"identity")
+-- or when we want to be able to set things after pag e1:
+--
+-- lpdf.registerdocumentfinalizer(setupidentity,1,"identity")
+
local function flushjavascripts()
local t = interactions.javascripts.flushpreambles()
if #t > 0 then
@@ -212,7 +220,7 @@ local function flushjavascripts()
local name, script = t[i][1], t[i][2]
local j = pdfdictionary {
S = pdf_javascript,
- JS = pdfreference(pdfimmediateobject("stream",script)),
+ JS = pdfreference(pdfflushstreamobject(script)),
}
a[#a+1] = pdfstring(name)
a[#a+1] = pdfreference(pdfflushobject(j))