diff options
author | Karl Berry <karl@freefriends.org> | 2015-05-11 21:37:36 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-05-11 21:37:36 +0000 |
commit | 0053a5222ec78ba41126c246eafd8cdb02f9a56a (patch) | |
tree | 22b38b1430bb1084ec8357362fc51d55ffd2fddb /Master/texmf-dist/tex/context/base/lpdf-wid.lua | |
parent | c4e86cc3b89e06b5f6a6ea80c907cfa69a7231da (diff) |
context/11may15
git-svn-id: svn://tug.org/texlive/trunk@37341 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lpdf-wid.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/lpdf-wid.lua | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/context/base/lpdf-wid.lua b/Master/texmf-dist/tex/context/base/lpdf-wid.lua index 895bbd3ffb2..22971c2b710 100644 --- a/Master/texmf-dist/tex/context/base/lpdf-wid.lua +++ b/Master/texmf-dist/tex/context/base/lpdf-wid.lua @@ -177,10 +177,27 @@ local function analyzetransparency(transparencyvalue) end -- Attachments +local nofattachments = 0 +local attachments = { } +local filestreams = { } +local referenced = { } +local ignorereferenced = true -- fuzzy pdf spec .. twice in attachment list, can become an option +local tobesavedobjrefs = utilities.storage.allocate() +local collectedobjrefs = utilities.storage.allocate() + +local fileobjreferences = { + collected = collectedobjrefs, + tobesaved = tobesavedobjrefs, +} + +job.fileobjreferences = fileobjreferences -local nofattachments, attachments, filestreams, referenced = 0, { }, { }, { } +local function initializer() + collectedobjrefs = job.fileobjreferences.collected or { } + tobesavedobjrefs = job.fileobjreferences.tobesaved or { } +end -local ignorereferenced = true -- fuzzy pdf spec .. twice in attachment list, can become an option +job.register('job.fileobjreferences.collected', tobesavedobjrefs, initializer) local function flushembeddedfiles() if next(filestreams) then @@ -209,6 +226,7 @@ function codeinjections.embedfile(specification) local hash = specification.hash or filename local keepdir = specification.keepdir -- can change local usedname = specification.usedname + local filetype = specification.filetype if filename == "" then filename = nil end @@ -246,11 +264,20 @@ function codeinjections.embedfile(specification) end end end - usedname = usedname ~= "" and usedname or filename + -- needs to cleaned up: + usedname = usedname ~= "" and usedname or filename or name local basename = keepdir == true and usedname or file.basename(usedname) -local basename = gsub(basename,"%./","") - local savename = file.addsuffix(name ~= "" and name or basename,"txt") -- else no valid file - local a = pdfdictionary { Type = pdfconstant("EmbeddedFile") } + local basename = gsub(basename,"%./","") + local savename = name ~= "" and name or basename + if not filetype or filetype == "" then + filetype = name and (filename and file.suffix(filename)) or "txt" + end + savename = file.addsuffix(savename,filetype) -- type is mandate for proper working in viewer + local mimetype = specification.mimetype + local a = pdfdictionary { + Type = pdfconstant("EmbeddedFile"), + Subtype = mimetype and mimetype ~= "" and pdfconstant(mimetype) or nil, + } local f if data then f = pdfflushstreamobject(data,a) @@ -265,6 +292,7 @@ local basename = gsub(basename,"%./","") UF = pdfstring(savename), EF = pdfdictionary { F = pdfreference(f) }, Desc = title ~= "" and pdfunicode(title) or nil, + -- AFRelationship = pdfconstant("Source"), -- some day maybe, not mandate } local r = pdfreference(pdfflushobject(d)) filestreams[hash] = r @@ -318,6 +346,10 @@ function nodeinjections.attachfile(specification) aref = codeinjections.embedfile(specification) attachments[registered] = aref end + local reference = specification.reference + if reference and aref then + tobesavedobjrefs[reference] = aref[1] + end if not aref then report_attachment("skipping attachment, registered %a",registered) -- already reported |