[NTG-context] doublesided PDF - first and last page singlesided

Aditya Mahajan adityam at umich.edu
Mon Apr 16 00:29:18 CEST 2012


On Mon, 16 Apr 2012, Jan Heinen wrote:

> I was lucky to get a fast answer - but with your code I don't get the right 
> result:
>
> -- start your code
>
> \startmode[booklet]
> \setuppapersize[A5][A4,landscape]
> \setuparranging[2SIDE]
> \stopmode
> \starttext
> First page
> \startmode[booklet]
> \null \page
> \stopmode
> etc.
> \stoptext
>
> Thomas
>
> -- stop
>
> With your code I get:
>
> 1 2      first page of the pdf
> 3 4      second
> 5 6      third
> 7 8      fourth
>
>
>
> But I want to get:
>
> 1         first page of the pdf (coverpage)
> 2 3      second
> 4 5      third
> 6 7      fourth
> 8         fifth (coverpage)
>
>
> I know how to use with modes - but the answer must be an other.
>
> Maybe I have to explain it more clearly:
>
> on the first PDF-Page (A5) there should be only the cover-page (page 1)
>    \setuppapersize[A5][A5]
>
>     \setuparranging[1SIDE]%<- I don't know how to write it - nothing was 
> working
>
>
> On the second PDF-Page there should be page 2 and page 3
>    \setuppapersize[A5][A4,landscape]
>
>     \setuparranging[2SIDE]
>
>
> It must be a problem lot's of people have when they make a book with ConTeXt
> and want to make a second PDF-version for the Internet.

If you don't mind creating another file to convert a given double sided 
pdf into the above format, you can use the following (pseudo code, 
untested, and might have typos)

get number of pages in the pdf
    \getfiguredimensions[filename]
    \edef\NOfPages{\noffigurepages}

insert the first page
    \startTEXpage[height=(A5 height}, width=(A5 width)]
    \externalfigure[filename][page=1]
    \stopTEXpage

loop and insert all but the last page (you may have to test if the number 
of pages are odd or even and use \numexpr(\NOfPages - 1) to find the last 
but one page:

\dostepwiserecurse{2}{2}{\LastButOnePage}
  { \startTEXpage[height=(A5 height), width=(A4 height)]
    \expanded{\externalfigure[filename][page=\recurselevel]}%
    \expanded{\externalfigure[filename][page=\numexpr\recurselevel+1\relax]}%
    \stopTEXpage
  }

If the number of pages is even, insert last page.


Aditya



More information about the ntg-context mailing list