Hans, would it be possible that \markpage could have page ranges as in the following sample? \setuplayout [backspace=0pt, topspace=0pt, width=middle, height=middle, location=middle, header=0pt, footer=0pt] \setupinteraction[state=start] \setupinteractionscreen[option={portrait, paper}, print=pages] \markpage[pages][100-300] \starttext \insertpages[i-context.pdf][width=0pt] \stoptext Many thanks for your help, Pablo -- http://www.ousia.tk
Pablo Rodriguez mailto:oinos@gmx.es 18. Juli 2018 um 18:19 Hans,
would it be possible that \markpage could have page ranges as in the following sample?
\setuplayout [backspace=0pt, topspace=0pt, width=middle, height=middle, location=middle, header=0pt, footer=0pt]
\setuplayout[page]
\setupinteraction[state=start] \setupinteractionscreen[option={portrait, paper}, print=pages] \markpage[pages][100-300] \starttext \insertpages[i-context.pdf][width=0pt] \stoptext
\startmarkpages[page] ... \stopmarkpages Wolfgang
On 07/18/2018 07:40 PM, Wolfgang Schuster wrote:
Pablo Rodriguez 18. Juli 2018 um 18:19 Hans,
would it be possible that \markpage could have page ranges as in the following sample?
\setuplayout [backspace=0pt, topspace=0pt, width=middle, height=middle, location=middle, header=0pt, footer=0pt]
\setuplayout[page]
Many thanks for your reply, Wolfgang. I didn’t know the already defined layout. In which source file is it defined? (I would like to know whether there are more already defined layouts.)
\insertpages[i-context.pdf][width=0pt] [...] \startmarkpages[page] ... \stopmarkpages
Sorry, but how do I apply that with to imposed pages with \insertpages? I know that \filterpages is there, but I need to have the complete document to print only some of the pages. Many thanks for your help, Pablo -- http://www.ousia.tk
Pablo Rodriguez mailto:oinos@gmx.es 18. Juli 2018 um 18:19 Hans,
would it be possible that \markpage could have page ranges as in the following sample?
\setuplayout [backspace=0pt, topspace=0pt, width=middle, height=middle, location=middle, header=0pt, footer=0pt] \setupinteraction[state=start] \setupinteractionscreen[option={portrait, paper}, print=pages] \markpage[pages][100-300] \starttext \insertpages[i-context.pdf][width=0pt] \stoptext
Many thanks for your help,
Pablo Wolfgang Schuster mailto:schuster.wolfgang@gmail.com 18. Juli 2018 um 19:40
Pablo Rodriguez mailto:oinos@gmx.es 18. Juli 2018 um 18:19 Hans,
would it be possible that \markpage could have page ranges as in the following sample?
\setuplayout [backspace=0pt, topspace=0pt, width=middle, height=middle, location=middle, header=0pt, footer=0pt]
\setuplayout[page]
\setupinteraction[state=start] \setupinteractionscreen[option={portrait, paper}, print=pages] \markpage[pages][100-300] \starttext \insertpages[i-context.pdf][width=0pt] \stoptext
\startmarkpages[page] ... \stopmarkpages
Wolfgang Pablo Rodriguez mailto:oinos@gmx.es 18. Juli 2018 um 20:44 On 07/18/2018 07:40 PM, Wolfgang Schuster wrote:
Pablo Rodriguez 18. Juli 2018 um 18:19 Hans,
would it be possible that \markpage could have page ranges as in the following sample?
\setuplayout [backspace=0pt, topspace=0pt, width=middle, height=middle, location=middle, header=0pt, footer=0pt] \setuplayout[page]
Many thanks for your reply, Wolfgang.
I didn’t know the already defined layout. In which source file is it defined? (I would like to know whether there are more already defined layouts.)
page-lay.mkiv
\insertpages[i-context.pdf][width=0pt] [...] \startmarkpages[page] ... \stopmarkpages
Sorry, but how do I apply that with to imposed pages with \insertpages?
I know that \filterpages is there, but I need to have the complete document to print only some of the pages.
You can get the number of pages of the included file with \getfiguredimensions. Afterwards you can use a loop where you add the markpage commands at the begin and end of the range, below is a simple example but it’s easy to write a better loop with Lua. \setuplayout[page] \setupinteraction[state=start] \setupinteractionscreen[option={portrait, paper}, print=pages] \starttext \getfiguredimensions[i-context.pdf] \dostepwiserecurse{1}{99}{1}{\externalfigure[i-context.pdf][height=\textheight,page=\recurselevel]} \startmarkpages[page] \dostepwiserecurse{100}{300}{1}{\externalfigure[i-context.pdf][height=\textheight,page=\recurselevel]} \stopmarkpages \dostepwiserecurse{301}{\noffigurepages}{1}{\externalfigure[i-context.pdf][height=\textheight,page=\recurselevel]} \stoptext Wolfgang
On 07/18/2018 09:08 PM, Wolfgang Schuster wrote:
Sorry, but how do I apply that with to imposed pages with \insertpages?
I know that \filterpages is there, but I need to have the complete document to print only some of the pages.
You can get the number of pages of the included file with \getfiguredimensions.
Afterwards you can use a loop where you add the markpage commands at the begin and end of the range, below is a simple example but it’s easy to write a better loop with Lua. I see that not having a way to specify ranges in \markpages makes complex to specify many ranges in a document.
Sorry, I understood the solution (I used a Lua loop for to impose pages in a new PDF document some time ago), but I cannot stop thinking why the approach to get page ranges looks so complex to me. Many thanks for your help, Pablo -- http://www.ousia.tk
On 07/18/2018 09:08 PM, Wolfgang Schuster wrote:
[...] Afterwards you can use a loop where you add the markpage commands at the begin and end of the range, below is a simple example but it’s easy to write a better loop with Lua.
\setuplayout[page] \setupinteraction[state=start] \setupinteractionscreen[option={portrait, paper}, print=pages] \starttext \getfiguredimensions[i-context.pdf] \dostepwiserecurse{1}{99}{1}{\externalfigure[i-context.pdf][height=\textheight,page=\recurselevel]} \startmarkpages[page] \dostepwiserecurse{100}{300}{1}{\externalfigure[i-context.pdf][height=\textheight,page=\recurselevel]} \stopmarkpages \dostepwiserecurse{301}{\noffigurepages}{1}{\externalfigure[i-context.pdf][height=\textheight,page=\recurselevel]} \stoptext
Wolfgang a different approach would be (code was mainly provided by anoter person): \startluacode function document.splitarray(inputstr, sep) local t={} for str in inputstr:gmatch("([^"..sep.."]+)") do table.insert(t, str) end return t end function document.getpagearray(page_ranges) local page_array={} local ranges = document.splitarray(page_ranges, ",") for _, pp in ipairs(ranges) do if string.find(pp, "-") then aux = document.splitarray(pp, "-") for i=tonumber(aux[1]), tonumber(aux[2]), 1 do table.insert(page_array, i) end else table.insert(page_array, tonumber(pp)) end end return page_array end function document.printmarkedpageranges(tag, page_ranges) page_array = document.getpagearray(page_ranges) context("\\markpage[" .. tag .. "][" .. table.concat(page_array, ", ") .. "]") end \stopluacode \def\getmarkedpageranges#1#2{% \ctxlua{document.printmarkedpageranges("#1","#2")}} \setuplayout[page] \setupinteraction[state=start] \setupinteractionscreen[option={portrait, paper}, print=pages] \getmarkedpageranges{pages}{5, 25-30, 100-200, 235, 298, 304} \starttext \insertpages[i-context.pdf][width=0pt] \stoptext This makes easier to add more complex page intervals (such as the one above). Before adding this to the wiki, my question would be whether it might not be easier to add page ranges to \markpage. I mean, as a standard user I think there is too much code (which may be improved and made part of ConTeXt) for such a simple need. Of course, I may be missing the whole point in this issue. I would really appreciate, if someone could explain me what is wrong in my assumption that \markpages need also page intervals. Many thanks for your help, Pablo -- http://www.ousia.tk
On 7/19/2018 9:56 PM, Pablo Rodriguez wrote:
On 07/18/2018 09:08 PM, Wolfgang Schuster wrote:
[...] Afterwards you can use a loop where you add the markpage commands at the begin and end of the range, below is a simple example but it’s easy to write a better loop with Lua.
\setuplayout[page] \setupinteraction[state=start] \setupinteractionscreen[option={portrait, paper}, print=pages] \starttext \getfiguredimensions[i-context.pdf] \dostepwiserecurse{1}{99}{1}{\externalfigure[i-context.pdf][height=\textheight,page=\recurselevel]} \startmarkpages[page] \dostepwiserecurse{100}{300}{1}{\externalfigure[i-context.pdf][height=\textheight,page=\recurselevel]} \stopmarkpages \dostepwiserecurse{301}{\noffigurepages}{1}{\externalfigure[i-context.pdf][height=\textheight,page=\recurselevel]} \stoptext
Wolfgang
a different approach would be (code was mainly provided by anoter person):
\startluacode function document.splitarray(inputstr, sep) local t={} for str in inputstr:gmatch("([^"..sep.."]+)") do table.insert(t, str) end return t end
function document.getpagearray(page_ranges) local page_array={} local ranges = document.splitarray(page_ranges, ",") for _, pp in ipairs(ranges) do if string.find(pp, "-") then aux = document.splitarray(pp, "-") for i=tonumber(aux[1]), tonumber(aux[2]), 1 do table.insert(page_array, i) end else table.insert(page_array, tonumber(pp)) end end return page_array end
function document.printmarkedpageranges(tag, page_ranges) page_array = document.getpagearray(page_ranges) context("\\markpage[" .. tag .. "][" .. table.concat(page_array, ", ") .. "]") end \stopluacode
\def\getmarkedpageranges#1#2{% \ctxlua{document.printmarkedpageranges("#1","#2")}} \setuplayout[page] \setupinteraction[state=start] \setupinteractionscreen[option={portrait, paper}, print=pages] \getmarkedpageranges{pages}{5, 25-30, 100-200, 235, 298, 304} \starttext \insertpages[i-context.pdf][width=0pt] \stoptext
This makes easier to add more complex page intervals (such as the one above).
Before adding this to the wiki, my question would be whether it might not be easier to add page ranges to \markpage.
nicer code local function getpagearray(page_ranges) local list = { } local ranges = string.split(page_ranges, ",") for i=1,#ranges do local f = string.split(ranges[i], "-") for i=tonumber(f[1]), tonumber(f[2] or f[1]) do list[i] = true end end return table.sortedkeys(list) end inspect(getpagearray("1-5,8,12-19")) or even better local function getpagearray(str,max) local list = { } local function add(i) list[i] = true end if max then utilities.parsers.stepper(str,max,add) else utilities.parsers.stepper(str,add) end return table.sortedkeys(list) end inspect(getpagearray("1-5,8,12-19,88-",100)) and then function document.printmarkedpageranges(tag,str) context.markpage({ tag }, getpagearray(str)) end
I mean, as a standard user I think there is too much code (which may be improved and made part of ConTeXt) for such a simple need.
Of course, I may be missing the whole point in this issue.
I would really appreciate, if someone could explain me what is wrong in my assumption that \markpages need also page intervals.
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 07/20/2018 12:19 AM, Hans Hagen wrote:
[...] or even better
local function getpagearray(str,max) local list = { } local function add(i) list[i] = true end if max then utilities.parsers.stepper(str,max,add) else utilities.parsers.stepper(str,add) end return table.sortedkeys(list) end [...] and then
function document.printmarkedpageranges(tag,str) context.markpage({ tag }, getpagearray(str)) end
Many thanks for your code, Hans. Is there no chance that this functionality could make its way into the ConTeXt source? Many thanks for your help, Pablo -- http://www.ousia.tk
participants (3)
-
Hans Hagen
-
Pablo Rodriguez
-
Wolfgang Schuster