# [xep-support] Next Installment of CoolTools -- "n-up" processing of pages

Kevin Brown kevin at renderx.com
Sun Dec 20 17:24:49 PST 2009

For this installment of CoolTools, I thought I would dig a little deeper
into the XEP Intermediate Format (XEPOUT).

We recently completed a project for a check processor where checks needed
to be designed with our tool VisualXSL but imposed into an output stream
in various "n-up" layouts. For that project, we created an XSL that
manipulated
the XEPOUT format and created a new document with various layouts on the
page
(like 4 checks in two columns, two rows ...). This specialized XSL also
injected incremental check numbers into the output.

So for CoolTools, we decided to create a style sheet that could process
any document into various print layouts.

It is based on the <xep:transform> element which can apply an affine matix
transformation to content. This is used to shrink pages to fit within the
output page. It is also based on the <xep:translate> element to move pages
in a grid layout in the new document.

http://www.renderx.com/reference.html#IntermediateFormatSpecification

The stylesheet is used to take an input document and create various styles
of output
by shrinking and translating input pages from the document into a new output
document
with the input document pages. It walks through the content, copy pages and
applying appropriate transformations to make a new document.

It does assume all the pages are uniform, all being the same dimensions of
the first
page. The scaling and configuration are based on this layout. It does work
with both
landscape and portrait documents. However, it does not work with documents
with
intra-document links or bookmarks. It is meant to produce a print output
document with
the desired n-up layout for print and we did not attempt to change all these

This style sheet supports the most common n-up formats:

2-up: Two per page
opposite final layout (inverts portrait to landscape and
visa-versa)
scaled to (width/height) for portrait
scaled to (height/width) for landscape
2 cols, 1 row for portrait
1 col, 2 rows for landscape
4-up: Four per page
same final layout
scaled to 1/2
6-up: Six per page
opposite final layout (inverts portrait to landscape and
visa-versa)
scaled to 1/2 (width/height) for portrait
scaled to 1/2 (height/width) for landscape
3 cols, 2 rows for portrait
2 cols, 3 rows for landscape
9-up: Nine per page
same final layout
scaled to 1/3
16-up: Sixteen per page
same final layout
scaled to 1/4

There is only one parameter to control the transformation "n-up". Use one of
the
values 2,4,6,9 or 16.

You can plug this into your own tool chain if you like. If you would like to
test
on your own, you could do so also from the command line. To create "XEPOUT"
from
the command line one would use the "-xep" format for the output:

xep -xml "my.xml" -xsl "my.xsl" -xep "my.xep"

Or is you are just using XSL FO as input, use:

xep "my.fo" -xep "my.xep"

With this XEPOUT document you would apply "N-up.xsl". You could use your
installed
copy of saxon ... something like:

java -classpath "path\to\saxon.jar" com.icl.saxon.StyleSheet "my.xep"
"N-up.xsl" > "myxep-nup.xep"

Last, you would process this new XEPOUT file with RenderX for pages:

xep -xep "myxep-nup.xep" -pdf "myxep-nup.pdf"

The download provided has the N-up.xsl along with tests of some outputs.

Samples:

http://www.xportability.com/CoolTools/4-up%20Sample.pdf
http://www.xportability.com/CoolTools/6-up%20Sample.pdf
http://www.xportability.com/CoolTools/16-up%20Sample.pdf

http://www.xportability.com/CoolTools/n-up.zip

If you have any questions, feel free to ask on the list or directly to me.

Enjoy!

Kevin Brown
(650) 327-1000 Direct
skype:kbrown01
kevin at renderx.com
sales at renderx.com
http://www.renderx.com

-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo at renderx.com from the address
you are subscribed from.