summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-10-10 21:09:32 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2018-10-10 21:09:32 +0200
commit9f36318b0e571bcbc93dc2112d01bbf2178ed020 (patch)
treed6b075357717f7fde0bdf73aa364dbbca5417c50 /scripts
parent753dd0cbafc567d4960c5fc4888ccb4e2302c64d (diff)
downloadcontext-9f36318b0e571bcbc93dc2112d01bbf2178ed020.tar.gz
2018-10-08 17:52:00
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-pdf.lua150
-rw-r--r--scripts/context/lua/mtxrun.lua6
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua6
-rw-r--r--scripts/context/stubs/unix/mtxrun6
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua6
5 files changed, 127 insertions, 47 deletions
diff --git a/scripts/context/lua/mtx-pdf.lua b/scripts/context/lua/mtx-pdf.lua
index ad115637b..2e73fa841 100644
--- a/scripts/context/lua/mtx-pdf.lua
+++ b/scripts/context/lua/mtx-pdf.lua
@@ -55,6 +55,8 @@ end
scripts = scripts or { }
scripts.pdf = scripts.pdf or { }
+local details = environment.argument("detail") or environment.argument("details")
+
local function loadpdffile(filename)
if not filename or filename == "" then
report("no filename given")
@@ -73,35 +75,87 @@ end
function scripts.pdf.info(filename)
local pdffile = loadpdffile(filename)
if pdffile then
- local catalog = pdffile.Catalog
- local info = pdffile.Info
- local pages = pdffile.pages
- local nofpages = pdffile.nofpages
+ local catalog = pdffile.Catalog
+ local info = pdffile.Info
+ local pages = pdffile.pages
+ local nofpages = pdffile.nofpages
- report("filename > %s",filename)
- report("pdf version > %s",catalog.Version)
- report("major version > %s",pdffile.majorversion or "?")
- report("minor version > %s",pdffile.minorversion or "?")
- report("number of pages > %s",nofpages)
- report("title > %s",info.Title)
- report("creator > %s",info.Creator)
- report("producer > %s",info.Producer)
- report("creation date > %s",info.CreationDate)
- report("modification date > %s",info.ModDate)
+ local unset = "<unset>"
- local width, height, start
- for i=1, nofpages do
- local page = pages[i]
- local bbox = page.CropBox or page.MediaBox or { 0, 0, 0, 0 }
- local w, h = bbox[4]-bbox[2],bbox[3]-bbox[1]
- if w ~= width or h ~= height then
- if start then
- report("cropbox > pages: %s-%s, width: %s, height: %s",start,i-1,width,height)
+ report("%-17s > %s","filename", filename)
+ report("%-17s > %s","pdf version", catalog.Version or unset)
+ report("%-17s > %s","major version", pdffile.majorversion or unset)
+ report("%-17s > %s","minor version", pdffile.minorversion or unset)
+ report("%-17s > %s","number of pages", nofpages or 0)
+ report("%-17s > %s","title", info.Title or unset)
+ report("%-17s > %s","creator", info.Creator or unset)
+ report("%-17s > %s","producer", info.Producer or unset)
+ report("%-17s > %s","creation date", info.CreationDate or unset)
+ report("%-17s > %s","modification date", info.ModDate or unset)
+
+ local function somebox(what)
+ local box = string.lower(what)
+ local width, height, start
+ for i=1, nofpages do
+ local page = pages[i]
+ local bbox = page[what] or page.MediaBox or { 0, 0, 0, 0 }
+ local w, h = bbox[4]-bbox[2],bbox[3]-bbox[1]
+ if w ~= width or h ~= height then
+ if start then
+ report("%-17s > pages: %s-%s, width: %s, height: %s",box,start,i-1,width,height)
+ end
+ width, height, start = w, h, i
end
- width, height, start = w, h, i
end
+ report("%-17s > pages: %s-%s, width: %s, height: %s",box,start,nofpages,width,height)
+ end
+
+ if details then
+ somebox("MediaBox")
+ somebox("ArtBox")
+ somebox("BleedBox")
+ somebox("CropBox")
+ somebox("TrimBox")
+ else
+ somebox("CropBox")
end
- report("cropbox > pages: %s-%s, width: %s, height: %s",start,nofpages,width,height)
+
+ -- if details then
+ local annotations = 0
+ for i=1, nofpages do
+ local page = pages[i]
+ local a = page.Annots
+ if a then
+ annotations = annotations + #a
+ end
+ end
+ if annotations > 0 then
+ report("%-17s > %s", "annotations",annotations)
+ end
+ -- end
+
+ -- if details then
+ local d = pdffile.destinations
+ local k = d and sortedkeys(d)
+ if k and #k > 0 then
+ report("%-17s > %s", "destinations",#k)
+ end
+ local d = pdffile.javascripts
+ local k = d and sortedkeys(d)
+ if k and #k > 0 then
+ report("%-17s > %s", "javascripts",#k)
+ end
+ local d = pdffile.widgets
+ if d and #d > 0 then
+ report("%-17s > %s", "widgets",#d)
+ end
+ local d = pdffile.embeddedfiles
+ local k = d and sortedkeys(d)
+ if k and #k > 0 then
+ report("%-17s > %s", "embeddedfiles",#k)
+ end
+ -- end
+
end
end
@@ -206,13 +260,18 @@ function scripts.pdf.fonts(filename)
local codes = { }
local chars = { }
local freqs = { }
+ local names = { }
if counts then
codes = sortedkeys(counts)
for i=1,#codes do
local k = codes[i]
- local c = utfchar(k)
- chars[i] = c
- freqs[i] = format("U+%05X %s %s",k,counts[k] > 1 and "+" or " ", c)
+ if k > 32 then
+ local c = utfchar(k)
+ chars[i] = c
+ freqs[i] = format("U+%05X %s %s",k,counts[k] > 1 and "+" or " ", c)
+ else
+ freqs[i] = format("U+%05X %s --",k,counts[k] > 1 and "+" or " ")
+ end
end
if basefont and unicode then
local b = gsub(basefont,"^.*%+","")
@@ -225,26 +284,40 @@ function scripts.pdf.fonts(filename)
codes[i] = format("U+%05X",codes[i])
end
end
+ local d = encoding and encoding.Differences
+ if d then
+ for i=1,#d do
+ local di = d[i]
+ if type(di) == "string" then
+ names[#names+1] = di
+ end
+ end
+ end
found[k] = {
basefont = basefont or "no basefont",
- encoding = encoding or "no encoding",
+ encoding = (d and "custom n=" .. #d) or "no encoding",
subtype = subtype or "no subtype",
- unicode = tounicode and "unicode" or "no unicode",
+ unicode = tounicode and "unicode" or "no vector",
chars = chars,
codes = codes,
freqs = freqs,
+ names = names,
}
end
- if environment.argument("detail") or environment.argument("details") then
+ if details then
for k, v in sortedhash(found) do
report("id : %s", k)
report("basefont : %s", v.basefont)
- report("encoding : %s", v.encoding)
+ report("encoding : % t", v.names)
report("subtype : %s", v.subtype)
report("unicode : %s", v.unicode)
- report("characters : % t", v.chars)
- report("codepoints : % t", v.codes)
+ if #v.chars > 0 then
+ report("characters : % t", v.chars)
+ end
+ if #v.codes > 0 then
+ report("codepoints : % t", v.codes)
+ end
report("")
end
for k, v in sortedhash(common) do
@@ -253,9 +326,16 @@ function scripts.pdf.fonts(filename)
report("")
end
else
- local results = { { "id", "basefont", "encoding", "subtype", "unicode", "characters" } }
+ local haschar = false
+ for k, v in sortedhash(found) do
+ if #v.chars > 0 then
+ haschar = true
+ break
+ end
+ end
+ local results = { { "id", "basefont", "encoding", "subtype", "unicode", haschar and "characters" or nil } }
for k, v in sortedhash(found) do
- results[#results+1] = { k, v.basefont, v.encoding, v.subtype, v.unicode, concat(v.chars," ") }
+ results[#results+1] = { k, v.basefont, v.encoding, v.subtype, v.unicode, haschar and concat(v.chars," ") or nil }
end
utilities.formatters.formatcolumns(results)
report(results[1])
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index bde079a86..60ca9a337 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -12424,7 +12424,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32361, stripped down to: 22577
+-- original size: 32613, stripped down to: 22577
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -24622,8 +24622,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 984267
--- stripped bytes : 347979
+-- original bytes : 984519
+-- stripped bytes : 348231
-- end library merge
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index bde079a86..60ca9a337 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -12424,7 +12424,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32361, stripped down to: 22577
+-- original size: 32613, stripped down to: 22577
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -24622,8 +24622,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 984267
--- stripped bytes : 347979
+-- original bytes : 984519
+-- stripped bytes : 348231
-- end library merge
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index bde079a86..60ca9a337 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -12424,7 +12424,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32361, stripped down to: 22577
+-- original size: 32613, stripped down to: 22577
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -24622,8 +24622,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 984267
--- stripped bytes : 347979
+-- original bytes : 984519
+-- stripped bytes : 348231
-- end library merge
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index bde079a86..60ca9a337 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -12424,7 +12424,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32361, stripped down to: 22577
+-- original size: 32613, stripped down to: 22577
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -24622,8 +24622,8 @@ end -- of closure
-- used libraries : l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 984267
--- stripped bytes : 347979
+-- original bytes : 984519
+-- stripped bytes : 348231
-- end library merge