summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/lpdf-swf.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2019-02-22 20:29:46 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2019-02-22 20:29:46 +0100
commit7b271baae19db1528fbe6621bdf50af89a5a336b (patch)
tree4fc24a8f2be20aa90e90f6e1bcb62d69f4946235 /tex/context/base/mkiv/lpdf-swf.lua
parent67b9965fe473d18f13ed4c40f1e4e008eb870322 (diff)
downloadcontext-7b271baae19db1528fbe6621bdf50af89a5a336b.tar.gz
2019-02-22 19:43:00
Diffstat (limited to 'tex/context/base/mkiv/lpdf-swf.lua')
-rw-r--r--tex/context/base/mkiv/lpdf-swf.lua46
1 files changed, 44 insertions, 2 deletions
diff --git a/tex/context/base/mkiv/lpdf-swf.lua b/tex/context/base/mkiv/lpdf-swf.lua
index 0ac107f8b..44e42dc5f 100644
--- a/tex/context/base/mkiv/lpdf-swf.lua
+++ b/tex/context/base/mkiv/lpdf-swf.lua
@@ -11,6 +11,7 @@ if not modules then modules = { } end modules ['lpdf-swf'] = {
local format, gsub = string.format, string.gsub
local concat = table.concat
+local formatters = string.formatters
local backends = backends
local lpdf = lpdf
@@ -33,6 +34,43 @@ local trace_swf = false trackers.register("backend.swf", function(v) trace_swf
local report_swf = logs.reporter("backend","swf")
+--------------------------------------------------------------------------------------
+
+local createimage = images.create
+local embedimage = images.embed
+
+local basepoints = number.dimenfactors.bp
+
+local f_image = formatters["%.6F 0 0 %.6F 0 0 cm /%s Do"]
+
+directives.register("pdf.stripzeros",function()
+ f_image = formatters["%.6N 0 0 %.6N 0 0 cm /%s Do"]
+end)
+
+local function package(image) -- see lpdf-u3d **
+ local boundingbox = image.bbox
+ local imagetag = "Im" .. image.index -- this is not ok
+ local resources = pdfdictionary {
+ ProcSet = lpdf.procset(),
+ Resources = pdfdictionary {
+ XObject = pdfdictionary {
+ [imagetag] = pdfreference(image.objnum)
+ }
+ }
+ }
+ local width = boundingbox[3]
+ local height = boundingbox[4]
+ local xform = createimage {
+ attr = resources(),
+ stream = f_image(width,height,imagetag),
+ bbox = { 0, 0, width/basepoints, height/basepoints },
+ }
+ embedimage(xform)
+ return xform
+end
+
+--------------------------------------------------------------------------------------
+
local activations = {
click = "XA",
page = "PO",
@@ -65,7 +103,10 @@ local function insertswf(spec)
local preview = checkedkey(display,"preview","string")
local toolbar = checkedkey(display,"toolbar","boolean")
- local embeddedreference = codeinjections.embedfile { file = filename }
+ local embeddedreference = codeinjections.embedfile {
+ file = filename,
+ compress = false,
+ }
local flash = pdfdictionary {
Subtype = pdfconstant("RichMediaConfiguration"),
@@ -122,6 +163,7 @@ local function insertswf(spec)
file = fullname,
usedname = usedname,
keepdir = true,
+ compress = false,
}
names[#names+1] = pdfstring(filename)
names[#names+1] = embeddedreference
@@ -275,7 +317,7 @@ local function insertswf(spec)
end
end
if figure then
- local image = img.package(figure.status.private)
+ local image = package(figure.status.private)
appearance = pdfdictionary { N = pdfreference(image.objnum) }
if trace_swf then
report_swf("using preview %s",preview)