In printing terminology, N-Up refers to the process of printing pages and laying them out over the destination pages in a 2-up, 3-up or more generally N-up pages per sheet.
This process is common in a wide variety of applications through the printing settings specified just before printing a document to a destination printer. The processing may take place at the application side when preparing the output to send to the printer, or it might occur on the printer’s side if the printer software or hardware can do N-up processing.
Amyuni PDF Creator N-Up processing without printing.
(Demo code available here. Note, for the latest PDF Creator binaries, please go to the Amyuni website and download the PDF Creator developer zip packages you require, ActiveX or .Net)
The PDF Creator can open documents like PDF or XPS or can be used to create content interactively or programmatically.
The new N-Up feature provides the possibility to change an existing document’s page layout into an N-up one without having to print to any printer.
Simply provide the destination layout settings and call the document method DoNUp() passing along the settings and then save the resulting updated document to a new file.
The settings that can be specified include items like:
- The destination paper size if it is to be different from the original document’s.
- The number of rows and columns to layout the source pages in the destination pages.
- The order (direction) to use for laying out source pages on the destination pages, e.g.: fill rows or columns first, from left to right or right to left, the gap distance between rows and columns.
- Whether to draw borders around the pages and whether to draw perforation marks between the rows and columns.
- The scaling to apply on the content of the source pages which can be automatic depending on the number of rows and columns and the destination page size, or a custom scale value which could come in handy in some use cases like when the user needs to add additional content or markings.
Settings UI dialog box:
![Image](https://www.amyuni.com/downloads/tn_nup/NUpSettingsDialog.png)
The use of the N-Up settings dialog box is optional. It is provided with the PDF Creator ActiveX developer and end user products. It is however implemented in the extensions acPDFCrExt.dll (part of both the end-user and developer products) which is loaded from the main PDFCreactiveX.dll.
The dialog box writes reads and writes the settings from and to a simple XML, for example:
![Image](https://www.amyuni.com/downloads/tn_nup/NUpXML.png)
For the PDF Creator ActiveX the settings parameter for the DoNUp() method can be in the form of a file name for the XML settings file or a COM IStream initialized with the XML settings.
For the PDF Creator.Net a wrapper object called IatNUpSettings with property setters and getters can be passed to the PDF Creator .Net document’s DoNUp() method. This object can also load from and save to XML in a System.IO.Stream instance.
Simple example using PDF Creator.Net:
Code: Select all
IacDocument pdf = new IacDocument();
IatNUpSettings nup = new IatNUpSettings();
// set some properties
// nup.Width = . . .
// nup.Length = . . .
// or
nup.KeepOriginalPaperSize = true;
nup.Rows = 4;
nup.Columns = 3
// . . .
pdf.Open( source );
pdf.DoNUp( nup );
pdf.Save( destination );
The demonstration code projects are available in this ZIP package which contains the items below. Note, for the latest PDF Creator binaries, please go to the Amyuni website and download the PDF Creator developer zip packages you require, ActiveX or .Net.
![Image](https://www.amyuni.com/downloads/tn_nup/PackageFolders.png)
- A C# console application that uses the PDF Creator ActiveX
- A C# console application that uses the PDF Creator .Net
- The PDF Creator binaries
- A couple of PDF files to try the samples with
Open a command prompt window and change directory to <solution dir>\Bin\Debug (or Release)
Try out the two demos:
NUpAx.exe
or
NUpNet.exe
without command line arguments first to see usage info.
Example with PDF Creactor ActiveX:
![Image](https://www.amyuni.com/downloads/tn_nup/NUpAxTestRun.png)
Result PDF file:
![Image](https://www.amyuni.com/downloads/tn_nup/NUpResult.png)