Dear list, this is a new experience deep inside LuaMetaTeX (for me). I need to compose a new document from selected pages (which are marked automatically and stored in /PrintPageRange) in a PDF document containing 1000 pages. It has to be one of the worst coding snippets ever written, but it works. It reads the array from /PrintPageRange, deploying it in context.filterpages. \startluacode function document.printrange_from_file(filename) range_array = pdfe.open(filename).Catalog.ViewerPreferences.PrintPageRange for i=1,#range_array do file_page = range_array[i] if file_pagerange == nil then file_pagerange = file_page else file_pagerange = file_pagerange .. " " .. file_page end end for str in file_pagerange:gmatch("([^%s]+)") do add_one = str + 1 if right_range == nil then right_range = add_one else right_range = right_range .. " " .. add_one end end spaces_in_pagerange = right_range:find(' ') local _, spaces_in_pagerange = right_range:gsub(" ", "") for actualspace=1,spaces_in_pagerange do if (actualspace % 2 == 0) then right_range = right_range:gsub(' ',',', 1) else right_range = right_range:gsub(' ',':', 1) end end context.filterpages( { filename }, { right_range }, { width = Opt } ) end \stopluacode \def\filterfrompagerange[#1]{% \ctxlua{document.printrange_from_file("#1")}} \setuplayout[page] \setupinteractionscreen[option={portrait, paper}] \starttext \filterfrompagerange[huge-book.pdf] \stoptext I copied and adapted all from Stackoverflow snippets. It is useful for me, since it file will be changing, page marking is automatic and filtering marked pages will be automatic too. But I wonder whether this may be useful to others. I wonder whether it makes sense to add it to the wiki. Let me know what you think about -- http://www.ousia.tk