\setuppapersize[A5][A4]
\setuplayout[location=middle, marking=on]
\setupinteraction
[title={TestDoc},
author={Anon}]
\setupbackend
[format=PDF/X-1a:2003,
intent={ISO Coated v2 300\letterpercent\space (ECI)}]
\setupinteractionscreen[width=max,height=max]
\startluacode
moduledata.mystuff={}
respecify_pdf_boxes = function()
local pdfverbose = lpdf.verbose
local factor = number.dimenfactors.bp
local f_value = string.formatters["\letterpercent.6N"]
local function boxvalue(n)
return pdfverbose(f_value(factor * n))
end
local paperwidth = tex.dimen.printpaperwidth
local paperheight = tex.dimen.printpaperheight
local pagewidth = tex.dimen.paperwidth
local pageheight = tex.dimen.paperheight
local bleedoffset = 3 /
number.dimenfactors.mm local pdfarray = lpdf.array
lpdf.addtopageattributes("MediaBox", pdfarray {
boxvalue(0),
boxvalue(0),
boxvalue(paperwidth),
boxvalue(paperheight),})
lpdf.addtopageattributes("CropBox", pdfarray {
boxvalue(0),
boxvalue(0),
boxvalue(paperwidth),
boxvalue(paperheight),})
lpdf.addtopageattributes("TrimBox", pdfarray {
boxvalue((paperwidth - pagewidth) / 2),
boxvalue((paperheight - pageheight) / 2),
boxvalue((paperwidth + pagewidth) / 2),
boxvalue((paperheight + pageheight) / 2),})
lpdf.addtopageattributes("BleedBox", pdfarray {
boxvalue((paperwidth - pagewidth) / 2 - bleedoffset),
boxvalue((paperheight - pageheight) / 2 - bleedoffset),
boxvalue((paperwidth + pagewidth) / 2 + bleedoffset),
boxvalue((paperheight + pageheight) / 2 + bleedoffset),})
end
moduledata.mystuff.respecify_pdf_boxes = respecify_pdf_boxes
lpdf.registerpagefinalizer(moduledata.mystuff.respecify_pdf_boxes, "respecify pdf boxes")
\stopluacode
\starttext
test
\stoptext