On Mon, 22 Aug 2022, Jethro Djan via ntg-context wrote:
Thanks for the solution Pablo. It works well.
I wanted to add more pdfs (which also has many pages) and found it was easier for me to reason in the lua side of things. This is what I have at the moment:
\starttext \startluacode local function doc(fil) return fil..[[.pdf]] end
local function disppdf(fname) n = 1 repeat context.externalfigure({fname},{ page = n, width = "200mm", scale = "950" }) n = n + 1 until n == context(context.noffigurepages) end
local pdffiles = {"ass1", "ass2", "ass3", "ass4", "ass5", "ass6", "ass7", "ass8"} for index=1,#pdffiles do local f = doc(pdffiles[index]) context.getfiguredimensions({f}) disppdf(pdffiles[index]) end \stopluacode \stoptext
I didn’t know how to get an array (or indexed table or whatever you call it) in ConTeXt/Tex. My problem is now with context(context.noffigurepages). It doesn’t produce an integer so n is being compared to nil. Am I calling it wrong? All I want to do is call \noffigurepages from the lua side. Is there something I am missing?
For a more low-level interface to finding the number of pages, see: https://adityam.github.io/context-blog/post/include-multi-page-pdf/ Aditya