Page shuffling
Yesterday I came across a Reddit question:
“I have a pdf where the pages somehow got warped into page 2 then 1 then 4 then 3 then 6 then 5…etc Everything is right except the even pages are a step ahead of the odds.”
This is very easy to do with the speedata Publisher:
<Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<Record element="data">
<SetVariable variable="fn" select="'fivepages.pdf'" />
<SetVariable variable="cp" select="sd:number-of-pages($fn)" />
<Loop select="$cp div 2 " variable="i">
<PlaceObject row="0mm" column="0mm">
<Image file="{$fn}" page="{$i * 2}" />
</PlaceObject>
<ClearPage />
<PlaceObject row="0mm" column="0mm">
<Image file="{$fn}" page="{$i * 2 - 1}" />
</PlaceObject>
<ClearPage />
</Loop>
<Switch>
<Case test="sd:odd($cp)">
<PlaceObject row="0mm" column="0mm">
<Image file="{$fn}" page="{$cp}" />
</PlaceObject>
</Case>
</Switch>
</Record>
</Layout>